有没有办法配置 Apache Tika,以块的形式解析数据?假设数据分为 10 个块。它可以在收到每个块时解析它吗?或者它只能在获得所有 10 个块时解析?
public OutputStream parse(InputStream instream) {
OutputStream outstream = new ByteArrayOutputStream();
ToXMLContentHandler h = new ToXMLContentHandler();
AutoDetectParser parser = new AutoDetectParser();
ParseContext context = new ParseContext();
Metadata metadata = new Metadata();
XHTMLContentHandler h1 = new XHTMLContentHandler(h, metadata);
try {
parser.parse(instream, h1, metadata, context);
outstream.write(h1.toString().getBytes(Charset.forName("UTF-8")));
} catch (TikaException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return outstream;
}
对此有什么想法吗?