You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by pe...@apache.org on 2020/12/14 01:22:28 UTC
[tika] branch main updated: Simplify method
Tika#parseToString(InputStream, Metadata)
This is an automated email from the ASF dual-hosted git repository.
peterlee pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git
The following commit(s) were added to refs/heads/main by this push:
new aec354e Simplify method Tika#parseToString(InputStream, Metadata)
aec354e is described below
commit aec354eaf6f98402508f34c1e7a1d1b9b9fc9582
Author: PeterAlfredLee <pe...@gmail.com>
AuthorDate: Mon Nov 23 14:49:58 2020 +0800
Simplify method Tika#parseToString(InputStream, Metadata)
Replace with `return parseToString(stream, metadata, maxStringLength);`
---
tika-core/src/main/java/org/apache/tika/Tika.java | 17 +----------------
1 file changed, 1 insertion(+), 16 deletions(-)
diff --git a/tika-core/src/main/java/org/apache/tika/Tika.java b/tika-core/src/main/java/org/apache/tika/Tika.java
index a14dced..afb8630 100644
--- a/tika-core/src/main/java/org/apache/tika/Tika.java
+++ b/tika-core/src/main/java/org/apache/tika/Tika.java
@@ -488,22 +488,7 @@ public class Tika {
*/
public String parseToString(InputStream stream, Metadata metadata)
throws IOException, TikaException {
- WriteOutContentHandler handler =
- new WriteOutContentHandler(maxStringLength);
- try {
- ParseContext context = new ParseContext();
- context.set(Parser.class, parser);
- parser.parse(
- stream, new BodyContentHandler(handler), metadata, context);
- } catch (SAXException e) {
- if (!handler.isWriteLimitReached(e)) {
- // This should never happen with BodyContentHandler...
- throw new TikaException("Unexpected SAX processing failure", e);
- }
- } finally {
- stream.close();
- }
- return handler.toString();
+ return parseToString(stream, metadata, maxStringLength);
}
/**