-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestMain.java
More file actions
57 lines (48 loc) · 1.19 KB
/
Copy pathTestMain.java
File metadata and controls
57 lines (48 loc) · 1.19 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import java.io.File;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
/**
*
* @author Chuka Okoye
*
*/
public class TestMain {
/**
* @param args
*/
public static void main(String[] args)
{
File file = new File("/Users/Chuka/Documents/workspace/Yelp_Java/src/testdata/test1.txt"); //Document
String searchKeyword = "japanese koryori-ya koryori ya"; //Search keyword
FileInputStream fis = null;
BufferedInputStream bis = null;
DataInputStream dis = null;
StringBuffer buf = new StringBuffer();
try
{
fis = new FileInputStream(file);
bis = new BufferedInputStream(fis);
dis = new DataInputStream(bis);
while(dis.available() != 0)
{
buf.append(dis.readLine());
}
fis.close();
bis.close();
dis.close();
}
catch(FileNotFoundException e)
{
System.out.println("File was not found");
}
catch(IOException e)
{
System.out.println("An I/O error occured.");
}
HighlightDocument highlighter = new HighlightDocument(buf.toString());
System.out.println("**MOST RELEVANT** "+highlighter.search(searchKeyword));
}
}