public boolean nextFile() { boolean has = inputStream.nextFile(); if (has && charset.equals(UTF_8)) { skipBom(); } return has; }
@Override public InputStreamWithHints openNextWithHints() throws IOException { if (!files.nextFile()) { return null; } return new InputStreamWithHints( new GZIPInputStream(files, 8 * 1024), fileInput.hintOfCurrentInputFileNameForLogging().orElse(null) ); }
@Override public InputStreamWithHints openNextWithHints() throws IOException { if (!files.nextFile()) { return null; } return new InputStreamWithHints( new BZip2CompressorInputStream(files, true), fileInput.hintOfCurrentInputFileNameForLogging().orElse(null) ); }
while (in.nextFile()) { final String fileName = input.hintOfCurrentInputFileNameForLogging().orElse("-");
@Test public void testRandomReadWrite() throws Exception { newOutputStream(); out.nextFile(); ByteArrayOutputStream expectedOut = new ByteArrayOutputStream(); Random rand = runtime.getRandom(); byte[] buffer = new byte[rand.nextInt() % 1024 + 1024]; for (int i = 0; i < 256; i++) { rand.nextBytes(buffer); expectedOut.write(buffer); out.write(buffer); } out.finish(); byte[] expected = expectedOut.toByteArray(); byte[] actual = new byte[expected.length]; newInputStream(); in.nextFile(); int pos = 0; while (pos < actual.length) { int n = in.read(actual, pos, actual.length - pos); if (n < 0) { break; } pos += n; } assertEquals(expected.length, pos); assertArrayEquals(expected, actual); }