Skip to content

Commit ea96c87

Browse files
committed
update
1 parent 72b91c3 commit ea96c87

15 files changed

+324
-0
lines changed

.classpath

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
<classpathentry kind="lib" path="/var/www/java/jackson-annotations-2.9.5.jar"/>
1212
<classpathentry kind="lib" path="/var/www/java/jackson-core-2.9.5.jar"/>
1313
<classpathentry kind="lib" path="/var/www/java/jackson-databind-2.9.5.jar" sourcepath="/home/kevingates/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.9.5/jackson-databind-2.9.5-sources.jar"/>
14+
<classpathentry kind="lib" path="/var/www/java/poi-3.0-rc4-20070503.jar"/>
1415
<classpathentry kind="output" path="bin"/>
1516
</classpath>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package kevinGates;
2+
3+
import java.io.FileNotFoundException;
4+
import java.io.FileOutputStream;
5+
import java.io.IOException;
6+
import java.io.*;
7+
8+
public class ApachePOIExcelWrite {
9+
10+
private static final String FILE_NAME = "/tmp/test.text";
11+
12+
public static void main(String[] args) throws IOException {
13+
14+
excel();
15+
//System.out.println("Done");
16+
}
17+
18+
public static void excel() throws IOException {
19+
String str = "Hello";
20+
BufferedWriter writer = new BufferedWriter(new FileWriter(FILE_NAME));
21+
writer.write(str);
22+
23+
writer.close();
24+
}
25+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package kevinGates;
2+
3+
import java.util.ArrayList;
4+
import java.util.Iterator;
5+
import java.util.List;
6+
7+
public class ArrayListLoopingExample {
8+
9+
public static void main(String[] args) {
10+
11+
List<String> list = new ArrayList<String>();
12+
list.add("Text 1");
13+
list.add("Text 2");
14+
list.add("Text 3");
15+
16+
System.out.println("#1 normal for loop");
17+
for (int i = 0; i < list.size(); i++) {
18+
System.out.println(list.get(i));
19+
}
20+
21+
System.out.println("#2 advance for loop");
22+
for (String temp : list) {
23+
System.out.println(temp);
24+
}
25+
26+
System.out.println("#3 while loop");
27+
int j = 0;
28+
while (list.size() > j) {
29+
System.out.println(list.get(j));
30+
j++;
31+
}
32+
33+
System.out.println("#4 iterator");
34+
Iterator<String> iterator = list.iterator();
35+
while (iterator.hasNext()) {
36+
System.out.println(iterator.next());
37+
}
38+
}
39+
40+
}

src/kevinGates/CSVExample.java

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package kevinGates;
2+
3+
import java.io.File;
4+
import java.io.FileNotFoundException;
5+
import java.io.PrintWriter;
6+
7+
public class CSVExample {
8+
9+
public static void main(String[]args) throws FileNotFoundException{
10+
//exportAsCsv();
11+
String pairDays = "LTC_06/15";
12+
13+
//String s1="java string split method by javatpoint";
14+
String[] pairDaysArray=pairDays.split("_");//splits the string based on whitespace
15+
//using java foreach loop to print elements of string array
16+
System.out.println(pairDaysArray[0]);
17+
System.out.println(pairDaysArray[1]);
18+
19+
// for(String pairDay:pairDaysArray){
20+
// System.out.println(pairDay);
21+
// }
22+
23+
}
24+
25+
public static void exportAsCsv() throws FileNotFoundException{
26+
String path = "/var/www/java/javaTutorial/src/kevinGates/holdings.csv";
27+
//String path = "/var/www/java/javaTutorial/src/kevinGates/trades.csv";
28+
String pairDays = "LTC_06/15";
29+
PrintWriter pw = new PrintWriter(new File(path));
30+
31+
StringBuilder sb = new StringBuilder();
32+
sb.append("id");
33+
sb.append(',');
34+
sb.append("Name");
35+
sb.append('\n');
36+
int k = 1;
37+
while(k<20) {
38+
39+
sb.append("1");
40+
sb.append(',');
41+
sb.append("Prashant Ghimire" + k);
42+
sb.append('\n');
43+
k++;
44+
}
45+
pw.write(sb.toString());
46+
pw.close();
47+
System.out.println("done!");
48+
}
49+
}

src/kevinGates/LanguageDetect.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package kevinGates;
2+
3+
import java.util.Locale;
4+
5+
public class LanguageDetect {
6+
7+
public static void main(String[] args) {
8+
// TODO Auto-generated method stub
9+
//Locale.getDefault()
10+
System.out.println("data="+Locale.getDefault());
11+
//String lang = Locale.getDisplayLanguage();
12+
//System.out.println("data="+lang);
13+
}
14+
15+
}

src/kevinGates/QueueExample.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package kevinGates;
2+
3+
import java.util.LinkedList;
4+
import java.util.Queue;
5+
6+
public class QueueExample {
7+
8+
public static void main(String[] args)
9+
{
10+
Queue<Integer> q = new LinkedList<>();
11+
12+
// Adds elements {0, 1, 2, 3, 4} to queue
13+
for (int i=0; i<5; i++)
14+
q.add(i);
15+
16+
// Display contents of the queue.
17+
System.out.println("Elements of queue-"+q);
18+
19+
// To remove the head of queue.
20+
int removedele = q.remove();
21+
System.out.println("removed element-" + removedele);
22+
23+
System.out.println(q);
24+
25+
// To view the head of queue
26+
int head = q.peek();
27+
System.out.println("head of queue-" + head);
28+
29+
// Rest all methods of collection interface,
30+
// Like size and contains can be used with this
31+
// implementation.
32+
int size = q.size();
33+
System.out.println("Size of queue-" + size);
34+
}
35+
36+
}

src/kevinGates/StringExample.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ public static void main(String[] args) {
66
// TODO Auto-generated method stub
77
String Str = new String("{ref_1=0.1, ref_2=0.2}");
88
System.out.println(replaceExample(Str));
9+
10+
String data = "";
11+
if(data.length() <= 2) {
12+
System.out.println("enough");
13+
} else {
14+
System.out.println("".substring(0,2));
15+
}
16+
917
}
1018

1119
public static String replaceExample(String stringData) {
@@ -15,4 +23,6 @@ public static String replaceExample(String stringData) {
1523

1624
return stringData;
1725
}
26+
27+
finalize
1828
}

src/kevinGates/User.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package kevinGates;
2+
3+
public class User {
4+
private Integer id;
5+
6+
private String name;
7+
8+
private String email;
9+
10+
public Integer getId() {
11+
return id;
12+
}
13+
14+
public void setId(Integer id) {
15+
this.id = id;
16+
}
17+
18+
public String getName() {
19+
return name;
20+
}
21+
22+
public void setName(String name) {
23+
this.name = name;
24+
}
25+
26+
public String getEmail() {
27+
return email;
28+
}
29+
30+
public void setEmail(String email) {
31+
this.email = email;
32+
}
33+
34+
35+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package kevinGates;
2+
3+
import kevinGates.packageExample.User;
4+
5+
public class UserImplementInterface implements UserInterface {
6+
7+
public static void main(String[] args) {
8+
// TODO Auto-generated method stub
9+
User user = new User();
10+
user.setEmail("[email protected]");
11+
user.setName("Kevin gates");
12+
13+
System.out.println("data="+user.data());
14+
}
15+
16+
// public void insert() {
17+
//
18+
// }
19+
//
20+
// public void update() {
21+
//
22+
// }
23+
//
24+
// public void delete() {
25+
//
26+
// }
27+
}

src/kevinGates/UserInterface.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package kevinGates;
2+
3+
public interface UserInterface {
4+
public void insert();
5+
public void update();
6+
public void delete();
7+
}

src/kevinGates/holdings.csv

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
id,Name
2+
1,Prashant Ghimire1
3+
1,Prashant Ghimire2
4+
1,Prashant Ghimire3
5+
1,Prashant Ghimire4
6+
1,Prashant Ghimire5
7+
1,Prashant Ghimire6
8+
1,Prashant Ghimire7
9+
1,Prashant Ghimire8
10+
1,Prashant Ghimire9
11+
1,Prashant Ghimire10
12+
1,Prashant Ghimire11
13+
1,Prashant Ghimire12
14+
1,Prashant Ghimire13
15+
1,Prashant Ghimire14
16+
1,Prashant Ghimire15
17+
1,Prashant Ghimire16
18+
1,Prashant Ghimire17
19+
1,Prashant Ghimire18
20+
1,Prashant Ghimire19
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package kevinGates.packageExample;
2+
3+
public class User {
4+
private Integer id;
5+
6+
private String name;
7+
8+
private String email;
9+
10+
public Integer getId() {
11+
return id;
12+
}
13+
14+
public void setId(Integer id) {
15+
this.id = id;
16+
}
17+
18+
public String getName() {
19+
return name;
20+
}
21+
22+
public void setName(String name) {
23+
this.name = name;
24+
}
25+
26+
public String getEmail() {
27+
return email;
28+
}
29+
30+
public void setEmail(String email) {
31+
this.email = email;
32+
}
33+
34+
public String data() {
35+
return this.id+"|"+this.name+"|"+this.email;
36+
}
37+
}
916 Bytes
Binary file not shown.

src/kevinGates/test.csv

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
id,Name
2+
1,Prashant Ghimire1
3+
1,Prashant Ghimire2
4+
1,Prashant Ghimire3
5+
1,Prashant Ghimire4
6+
1,Prashant Ghimire5
7+
1,Prashant Ghimire6
8+
1,Prashant Ghimire7
9+
1,Prashant Ghimire8
10+
1,Prashant Ghimire9
11+
1,Prashant Ghimire10
12+
1,Prashant Ghimire11
13+
1,Prashant Ghimire12
14+
1,Prashant Ghimire13
15+
1,Prashant Ghimire14
16+
1,Prashant Ghimire15
17+
1,Prashant Ghimire16
18+
1,Prashant Ghimire17
19+
1,Prashant Ghimire18
20+
1,Prashant Ghimire19

test.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
id,Name
2+
1,Prashant Ghimire

0 commit comments

Comments
 (0)