List of usage examples for edu.stanford.nlp.io IOUtils slurpInputStream
public static String slurpInputStream(InputStream input, String encoding) throws IOException
From source file:org.exist.xquery.corenlp.Tokenize.java
License:Open Source License
private String readUploadedTextDocument(final TextDocType textDocType) throws IOException { String text = ""; switch (textDocType) { case ODT://from ww w. jav a 2s .c om try (InputStream is = uploadedFileBase64String.getInputStream()) { TextDocument utd = ODPackage.createFromStream(is, "UserTextDocument").getTextDocument(); text = utd.getCharacterContent(true); //ooMode? } break; case DOCX: try (InputStream is = uploadedFileBase64String.getInputStream()) { POITextExtractor extractor = ExtractorFactory.createExtractor(is); text = extractor.getText(); } catch (InvalidFormatException ife) { LOG.error(ife); } catch (OpenXML4JException ox4e) { LOG.error(ox4e); } catch (XmlException xe) { LOG.error(xe); } break; case DOC: try (InputStream is = uploadedFileBase64String.getInputStream()) { POITextExtractor extractor = ExtractorFactory.createExtractor(is); text = extractor.getText(); } catch (InvalidFormatException ife) { LOG.error(ife); } catch (OpenXML4JException ox4e) { LOG.error(ox4e); } catch (XmlException xe) { LOG.error(xe); } break; case TXT: text = IOUtils.slurpInputStream(uploadedFileBase64String.getInputStream(), "UTF-8"); // Or null break; } return text; }