-
Notifications
You must be signed in to change notification settings - Fork 2
/
file_opener.java
35 lines (27 loc) · 956 Bytes
/
file_opener.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
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;
import org.apache.tika.Tika;
import org.apache.tika.exception.TikaException;
public class file_opener {
file_opener() throws IOException, TikaException{
Tika tika = new Tika();
File throwAway = new File("H:\\group project\\test.docx");
System.err.println("Tika initializing, this usually only takes a few seconds");
tika.parseToString(throwAway);
System.err.println("Tika initialized");
}
public String open(File file) throws IOException, TikaException{
Tika tika = new Tika();
try{
String testString = tika.parseToString(file);
return testString;
}catch(Exception e){System.err.println(file.getAbsolutePath() + " WAS NOT FOUND OR COULD NOT BE READ");}
return null;
}
public boolean supportedText(File file){
return false;
}
}