Apache Tika e limite de caracteres ao analisar documentos
Alguém poderia me ajudar a resolver o problema?
Pode ser feito assim
Tika tika = new Tika();
tika.setMaxStringLength(10*1024*1024);
Mas se você não usar o Tika diretamente, assim:
ContentHandler textHandler = new BodyContentHandler();
Metadata metadata = new Metadata();
Parser parser = new AutoDetectParser();
ParseContext ps = new ParseContext();
for (InputStream is : getInputStreams()) {
parser.parse(is, textHandler, metadata, ps);
is.close();
System.out.println("Title: " + metadata.get("title"));
System.out.println("Author: " + metadata.get("Author"));
}
Não há como configurá-lo, porque você não interage com oWriteOutContentHandler
. Btw está definido como-1
por padrão, o que significa que não há restrições. Mas a restrição resultante é de 100000 caractere
/**
* The maximum number of characters to write to the character stream.
* Set to -1 for no limit.
*/
private final int writeLimit;
/**
* Number of characters written so far.
*/
private int writeCount = 0;
private WriteOutContentHandler(Writer writer, int writeLimit) {
this.writer = writer;
this.writeLimit = writeLimit;
}
/**
* Creates a content handler that writes character events to
* the given writer.
*
* @param writer writer
*/
public WriteOutContentHandler(Writer writer) {
this(writer, -1);
}