@Test void extractContentShouldTakeIntoAccountCharset() throws Exception { InputStream inputStream = ClassLoader.getSystemResourceAsStream("documents/simple-text-iso-8859-1.txt"); assertThat(inputStream).isNotNull(); assertThat(textExtractor.extractContent(inputStream, ContentType.of("text/plain; charset=ISO-8859-1")) .getTextualContent()) .contains("\"é\" This text is not UTF-8 \"à\""); }
@Override public ParsedContent extractContent(InputStream inputStream, ContentType contentType) throws Exception { if (contentType != null && contentType.asString().startsWith("text/")) { Charset charset = contentType.charset().orElse(StandardCharsets.UTF_8); return new ParsedContent(Optional.ofNullable(IOUtils.toString(inputStream, charset)), new HashMap<>()); } else { return new ParsedContent(Optional.empty(), new HashMap<>()); } }
DefaultTextExtractor implements TextExtractor { @Override public ParsedContent extractContent(InputStream inputStream, ContentType contentType) throws Exception { if (contentType != null && contentType.asString().startsWith("text/")) { Charset charset = contentType.charset().orElse(StandardCharsets.UTF_8); return new ParsedContent(Optional.ofNullable(IOUtils.toString(inputStream, charset)), new HashMap<>()); } else { return new ParsedContent(Optional.empty(), new HashMap<>()); } } }
DefaultTextExtractor implements TextExtractor { @Override public ParsedContent extractContent(InputStream inputStream, ContentType contentType) throws Exception { if (contentType != null && contentType.asString().startsWith("text/")) { Charset charset = contentType.charset().orElse(StandardCharsets.UTF_8); return new ParsedContent(Optional.ofNullable(IOUtils.toString(inputStream, charset)), new HashMap<>()); } else { return new ParsedContent(Optional.empty(), new HashMap<>()); } }  }
DefaultTextExtractor implements TextExtractor { @Override public ParsedContent extractContent(InputStream inputStream, ContentType contentType) throws Exception { if (contentType != null && contentType.asString().startsWith("text/")) { Charset charset = contentType.charset().orElse(StandardCharsets.UTF_8); return new ParsedContent(Optional.ofNullable(IOUtils.toString(inputStream, charset)), new HashMap<>()); } else { return new ParsedContent(Optional.empty(), new HashMap<>()); } }  @Override ParsedContent extractContent(InputStream inputStream, ContentType contentType); }
DefaultTextExtractor implements TextExtractor { @Override public ParsedContent extractContent(InputStream inputStream, ContentType contentType) throws Exception { if (contentType != null && contentType.asString().startsWith("text/")) { Charset charset = contentType.charset().orElse(StandardCharsets.UTF_8); return new ParsedContent(Optional.ofNullable(IOUtils.toString(inputStream, charset)), new HashMap<>()); } else { return new ParsedContent(Optional.empty(), new HashMap<>()); } }  @Override ParsedContent extractContent(InputStream inputStream, ContentType contentType);  }