-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDictionary.java
More file actions
36 lines (33 loc) · 1.13 KB
/
Copy pathDictionary.java
File metadata and controls
36 lines (33 loc) · 1.13 KB
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
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.*;
public class Dictionary {
public void saveWord(Map<String,String> map)
{
Word w = new Word();
FileReader fr = null;
BufferedReader br = null;
try{
fr = new FileReader("dictionaries.txt");
br = new BufferedReader(fr);
String readWord;
while ((readWord = br.readLine()) != null) {
int j=0;
for(int i=0; i<readWord.length(); i++) {
j++;
if(Character.isSpaceChar(readWord.charAt(i))) {
break;
}
}
String tmpWord = readWord;
w.word_target = tmpWord.substring(0,j-1);
w.word_explain= readWord.substring(j);
map.put(w.word_target, w.word_explain);
}
br.close();
fr.close();
}catch (Exception e){
System.out.println("Chưa có file dictionaries.txt để thực hiện tra cứu từ");
}
}
}