@Test public void testHeadHandler() throws IOException { LOGGER.log(Level.INFO, "testing HeadHandler with: {0}/{1}/{2}", new Object[]{lineCnt, headLineCnt, totalCharCount}); RandomInputStream rndStream = new RandomInputStream(totalCharCount, lineCnt); HeadHandler handler = new HeadHandler(headLineCnt); assertTrue(totalCharCount >= HeadHandler.getBufferedReaderSize(), "number of characters to generate must be bigger than " + "HeadHandler internal buffer size"); handler.processStream(rndStream); assertTrue(handler.count() <= headLineCnt, "HeadHandler should not get more lines than was asked to"); assertEquals(totalCharCount, rndStream.getCharCount(), "HeadHandler should read all the characters from input stream"); String[] headLines = new String[handler.count()]; for (int i = 0; i < handler.count(); i++) { String line = handler.get(i); LOGGER.log(Level.INFO, "line [{0}]: {1}", new Object[]{i, line}); headLines[i] = line; } assertArrayEquals(headLines, Arrays.copyOfRange(rndStream.getResult().split("\n"), 0, handler.count()), "the lines retrieved by HeadHandler needs to match the input"); }
public HeadHandler(int maxLines) { this.maxLines = maxLines; this.charset = StandardCharsets.UTF_8; }
HeadHandler implements Executor.StreamHandler { public HeadHandler(int maxLines) { this.maxLines = maxLines; this.charset = StandardCharsets.UTF_8; } }
HeadHandler implements Executor.StreamHandler { public HeadHandler(int maxLines) { this.maxLines = maxLines; this.charset = StandardCharsets.UTF_8; } HeadHandler(int maxLines);  HeadHandler(int maxLines, Charset charset); }
HeadHandler implements Executor.StreamHandler { public HeadHandler(int maxLines) { this.maxLines = maxLines; this.charset = StandardCharsets.UTF_8; } HeadHandler(int maxLines);  HeadHandler(int maxLines, Charset charset); int count(); String get(int index); @Override void processStream(InputStream input); }
HeadHandler implements Executor.StreamHandler { public HeadHandler(int maxLines) { this.maxLines = maxLines; this.charset = StandardCharsets.UTF_8; } HeadHandler(int maxLines);  HeadHandler(int maxLines, Charset charset); int count(); String get(int index); @Override void processStream(InputStream input);  }