-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDictionary.java
More file actions
33 lines (24 loc) · 917 Bytes
/
Dictionary.java
File metadata and controls
33 lines (24 loc) · 917 Bytes
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
package sample.spl1;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
public class Dictionary {
private HashMap<String, String> map;
public Dictionary(String filePath) throws Exception{
map = new HashMap<String, String>();
BufferedReader mainBR = new BufferedReader(new InputStreamReader(new FileInputStream("src/sample/spl1/Translation.txt")));
String line = mainBR.readLine();
while(line != null){
int seperator = line.indexOf('|', 1);
map.put(line.substring(seperator+1), line.substring(1, seperator));
line = mainBR.readLine();
}
mainBR.close();
}
public String search(String word){
// if(word=="null")return word;
return map.get(word) +" "+ word;
}
}