-
Notifications
You must be signed in to change notification settings - Fork 0
/
Reader.java
48 lines (45 loc) · 1.29 KB
/
Reader.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import java.io.*;
import java.util.*;
class Reader {
public ArrayList<String> apiSheet = new ArrayList<>();
public Reader(String dic){
try{
File apiFile = new File(dic);
Scanner s = new Scanner(apiFile);
int x = 1;
int z = 1;
for(int y = 1; s.hasNextLine(); y++){
if(y == ((2*x)-1)){
s.nextLine();
x++;
}
/*
else if(y == 2*z){
s.nextLine();
z++;
}
*/ else{
String dicWord = s.nextLine();
apiSheet.add(dicWord);
}
}
String out = "new";
createFile("new", apiSheet);
}
catch(Exception e){
System.out.println("File not found ! ");
}
System.out.println(apiSheet);
}
private void createFile(String file, ArrayList<String> arrData) throws IOException {
FileWriter writer = new FileWriter(file + ".txt");
int size = arrData.size();
for (int i=0;i<size;i++) {
String str = arrData.get(i).toString();
writer.write(str);
if(i < size-1)
writer.write("\n");
}
writer.close();
}
}