final long bytesToWrite = length - skipLast - currentPos; IOUtil.transferByStream(in, out, bytesToWrite); in.close(); isFirstFile = false;
@Test(dataProvider = "filesToCompress") public void testCompressionLevel(final Path file, final String extension, final int lastDifference) throws IOException { final long origSize = Files.size(file); long previousSize = origSize; for (int compressionLevel = 1; compressionLevel <= 9; compressionLevel++) { final Path outFile = Files.createTempFile("tmp", extension); outFile.toFile().deleteOnExit(); IOUtil.setCompressionLevel(compressionLevel); Assert.assertEquals(IOUtil.getCompressionLevel(), compressionLevel); final InputStream inStream = IOUtil.openFileForReading(file); try (final OutputStream outStream = IOUtil.openFileForWriting(outFile.toFile())) { IOUtil.transferByStream(inStream, outStream, origSize); } final long newSize = Files.size(outFile); if (compressionLevel <= lastDifference) { Assert.assertTrue(previousSize > newSize); } else { Assert.assertTrue(previousSize >= newSize); } previousSize = newSize; } }
final long bytesToWrite = length - skipLast - currentPos; IOUtil.transferByStream(in, out, bytesToWrite); in.close(); isFirstFile = false;
IOUtil.transferByStream(blockIn, blockOut, remainingInBlock); blockOut.flush(); final long bytesToWrite = length - skipLast - currentPos; IOUtil.transferByStream(in, outputStream, bytesToWrite); } catch (final IOException ioe) { throw new RuntimeIOException(ioe);
IOUtil.transferByStream(blockIn, blockOut, remainingInBlock); blockOut.flush(); final long bytesToWrite = length - skipLast - currentPos; IOUtil.transferByStream(in, outputStream, bytesToWrite); } catch (final IOException ioe) { throw new RuntimeIOException(ioe);
IOUtil.transferByStream(blockIn, blockOut, remainingInBlock); blockOut.flush(); final long bytesToWrite = length - skipLast - currentPos; IOUtil.transferByStream(in, outputStream, bytesToWrite); } catch (final IOException ioe) { throw new RuntimeIOException(ioe);