tikaを使用して各種ドキュメントのコンテンツ抽出を行う
528 ワード
public static String extractData(String path){
String str = null;
Parser p= new AutoDetectParser();
BodyContentHandler hand= new BodyContentHandler(10000);
Metadata me=new Metadata();
ParseContext pct=new ParseContext();
InputStream is = null;
try {
is = new FileInputStream(path);
System.out.println(is.available());
p.parse(is, hand, me, pct);
str = hand.toString();
System.out.println(str);
} catch (Exception e) {
e.printStackTrace();
}
return str;
}