LineOrientedTextReader extends JCasResourceCollectionReader_ImplBase { @Override public void getNext(JCas aJCas) throws IOException, CollectionException { Resource res = nextFile(); initCas(aJCas, res); try (InputStream is = new BufferedInputStream(res.getInputStream())) { aJCas.setDocumentText(IOUtils.toString(is, "UTF-8")); } String t = aJCas.getDocumentText(); int start = 0; int end = t.indexOf('\n'); while (end >= 0) { createSentence(aJCas, start, end); start = end + 1; if (start < t.length()) { end = t.indexOf('\n', start); } else { end = -1; } } if (start < t.length()) { createSentence(aJCas, start, t.length()); } }  @Override void getNext(JCas aJCas); void trim(String aText, int[] aSpan); boolean isEmpty(int aBegin, int aEnd); boolean trimChar(final char aChar);  }
@Test public void test() throws Exception { JCas doc = JCasFactory.createJCas(); CollectionReader reader = createReader(LineOrientedTextReader.class, LineOrientedTextReader.PARAM_SOURCE_LOCATION, "LICENSE.txt"); reader.getNext(doc.getCas()); assertEquals(169, select(doc, Sentence.class).size()); assertEquals(0, select(doc, Token.class).size()); }