> Am 11.04.2017 um 14:47 schrieb bode...@apache.org: > > Repository: commons-compress > Updated Branches: > refs/heads/master 5ce60be9d -> 08113862c > > > reduce GC pressure by avoiding File(In|Out)putStreams
So you also saw the blog post by CloudBees ;-) Regards, Benedikt > > > Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo > Commit: > http://git-wip-us.apache.org/repos/asf/commons-compress/commit/08113862 > Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/08113862 > Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/08113862 > > Branch: refs/heads/master > Commit: 08113862c5dda6dfb0562d84db8db8f5f41bfa4a > Parents: 5ce60be > Author: Stefan Bodewig <bode...@apache.org> > Authored: Tue Apr 11 14:46:32 2017 +0200 > Committer: Stefan Bodewig <bode...@apache.org> > Committed: Tue Apr 11 14:46:32 2017 +0200 > > ---------------------------------------------------------------------- > .../archivers/ArchiveStreamFactory.java | 50 +++++++------- > .../commons/compress/archivers/Lister.java | 6 +- > .../archivers/cpio/CpioArchiveInputStream.java | 2 +- > .../compressors/CompressorStreamFactory.java | 8 +-- > .../pack200/TempFileCachingStreamBridge.java | 8 +-- > .../FileBasedScatterGatherBackingStore.java | 17 +++-- > src/site/xdoc/examples.xml | 68 ++++++++++---------- > 7 files changed, 83 insertions(+), 76 deletions(-) > ---------------------------------------------------------------------- > > > http://git-wip-us.apache.org/repos/asf/commons-compress/blob/08113862/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java > ---------------------------------------------------------------------- > diff --git > a/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java > > b/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java > index 38a1c4a..6ca0437 100644 > --- > a/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java > +++ > b/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java > @@ -59,26 +59,26 @@ import org.apache.commons.compress.utils.Sets; > * Compressing a ZIP-File: > * > * <pre> > - * final OutputStream out = new FileOutputStream(output); > + * final OutputStream out = Files.newOutputStream(output.toPath()); > * ArchiveOutputStream os = new > ArchiveStreamFactory().createArchiveOutputStream(ArchiveStreamFactory.ZIP, > out); > - * > + * > * os.putArchiveEntry(new ZipArchiveEntry("testdata/test1.xml")); > - * IOUtils.copy(new FileInputStream(file1), os); > + * IOUtils.copy(Files.newInputStream(file1.toPath()), os); > * os.closeArchiveEntry(); > * > * os.putArchiveEntry(new ZipArchiveEntry("testdata/test2.xml")); > - * IOUtils.copy(new FileInputStream(file2), os); > + * IOUtils.copy(Files.newInputStream(file2.toPath()), os); > * os.closeArchiveEntry(); > * os.close(); > * </pre> > - * > + * > * Decompressing a ZIP-File: > - * > + * > * <pre> > - * final InputStream is = new FileInputStream(input); > + * final InputStream is = Files.newInputStream(input.toPath()); > * ArchiveInputStream in = new > ArchiveStreamFactory().createArchiveInputStream(ArchiveStreamFactory.ZIP, is); > * ZipArchiveEntry entry = (ZipArchiveEntry)in.getNextEntry(); > - * OutputStream out = new FileOutputStream(new File(dir, entry.getName())); > + * OutputStream out = > Files.newOutputStream(dir.toPath().resolve(entry.getName())); > * IOUtils.copy(in, out); > * out.close(); > * in.close(); > @@ -95,51 +95,51 @@ public class ArchiveStreamFactory implements > ArchiveStreamProvider { > private static final int SIGNATURE_SIZE = 12; > > private static final ArchiveStreamFactory SINGLETON = new > ArchiveStreamFactory(); > - > + > /** > * Constant (value {@value}) used to identify the AR archive format. > * @since 1.1 > */ > public static final String AR = "ar"; > - > + > /** > * Constant (value {@value}) used to identify the ARJ archive format. > * Not supported as an output stream type. > * @since 1.6 > */ > public static final String ARJ = "arj"; > - > + > /** > * Constant (value {@value}) used to identify the CPIO archive format. > * @since 1.1 > */ > public static final String CPIO = "cpio"; > - > + > /** > * Constant (value {@value}) used to identify the Unix DUMP archive > format. > * Not supported as an output stream type. > * @since 1.3 > */ > public static final String DUMP = "dump"; > - > + > /** > * Constant (value {@value}) used to identify the JAR archive format. > * @since 1.1 > */ > public static final String JAR = "jar"; > - > + > /** > * Constant used to identify the TAR archive format. > * @since 1.1 > */ > public static final String TAR = "tar"; > - > + > /** > * Constant (value {@value}) used to identify the ZIP archive format. > * @since 1.1 > */ > public static final String ZIP = "zip"; > - > + > /** > * Constant (value {@value}) used to identify the 7z archive format. > * @since 1.8 > @@ -170,7 +170,7 @@ public class ArchiveStreamFactory implements > ArchiveStreamProvider { > map.put(toKey(name), provider); > } > } > - > + > private static Iterator<ArchiveStreamProvider> serviceLoaderIterator() { > return new ServiceLoaderIterator<>(ArchiveStreamProvider.class); > } > @@ -295,11 +295,11 @@ public class ArchiveStreamFactory implements > ArchiveStreamProvider { > > /** > * Sets the encoding to use for arj, jar, zip, dump, cpio and tar files. > Use null for the archiver default. > - * > + * > * @param entryEncoding the entry encoding, null uses the archiver > default. > * @since 1.5 > * @deprecated 1.10 use {@link #ArchiveStreamFactory(String)} to specify > the encoding > - * @throws IllegalStateException if the constructor {@link > #ArchiveStreamFactory(String)} > + * @throws IllegalStateException if the constructor {@link > #ArchiveStreamFactory(String)} > * was used to specify the factory encoding. > */ > @Deprecated > @@ -313,7 +313,7 @@ public class ArchiveStreamFactory implements > ArchiveStreamProvider { > > /** > * Creates an archive input stream from an archiver name and an input > stream. > - * > + * > * @param archiverName the archive name, > * i.e. {@value #AR}, {@value #ARJ}, {@value #ZIP}, {@value #TAR}, > {@value #JAR}, {@value #CPIO}, {@value #DUMP} or {@value #SEVEN_Z} > * @param in the input stream > @@ -327,7 +327,7 @@ public class ArchiveStreamFactory implements > ArchiveStreamProvider { > throws ArchiveException { > return createArchiveInputStream(archiverName, in, entryEncoding); > } > - > + > @Override > public ArchiveInputStream createArchiveInputStream(final String > archiverName, final InputStream in, > final String actualEncoding) throws ArchiveException { > @@ -393,9 +393,9 @@ public class ArchiveStreamFactory implements > ArchiveStreamProvider { > > /** > * Creates an archive output stream from an archiver name and an output > stream. > - * > + * > * @param archiverName the archive name, > - * i.e. {@value #AR}, {@value #ZIP}, {@value #TAR}, {@value #JAR} or > {@value #CPIO} > + * i.e. {@value #AR}, {@value #ZIP}, {@value #TAR}, {@value #JAR} or > {@value #CPIO} > * @param out the output stream > * @return the archive output stream > * @throws ArchiveException if the archiver name is not known > @@ -407,7 +407,7 @@ public class ArchiveStreamFactory implements > ArchiveStreamProvider { > throws ArchiveException { > return createArchiveOutputStream(archiverName, out, entryEncoding); > } > - > + > @Override > public ArchiveOutputStream createArchiveOutputStream( > final String archiverName, final OutputStream out, final String > actualEncoding) > @@ -463,7 +463,7 @@ public class ArchiveStreamFactory implements > ArchiveStreamProvider { > * Create an archive input stream from an input stream, autodetecting > * the archive type from the first few bytes of the stream. The > InputStream > * must support marks, like BufferedInputStream. > - * > + * > * @param in the input stream > * @return the archive input stream > * @throws ArchiveException if the archiver name is not known > > http://git-wip-us.apache.org/repos/asf/commons-compress/blob/08113862/src/main/java/org/apache/commons/compress/archivers/Lister.java > ---------------------------------------------------------------------- > diff --git a/src/main/java/org/apache/commons/compress/archivers/Lister.java > b/src/main/java/org/apache/commons/compress/archivers/Lister.java > index f8e5166..7df9591 100644 > --- a/src/main/java/org/apache/commons/compress/archivers/Lister.java > +++ b/src/main/java/org/apache/commons/compress/archivers/Lister.java > @@ -20,8 +20,8 @@ package org.apache.commons.compress.archivers; > > import java.io.BufferedInputStream; > import java.io.File; > -import java.io.FileInputStream; > import java.io.InputStream; > +import java.nio.file.Files; > > /** > * Simple command line application that lists the contents of an archive. > @@ -44,7 +44,7 @@ public final class Lister { > if (!f.isFile()) { > System.err.println(f + " doesn't exist or is a directory"); > } > - try (final InputStream fis = new BufferedInputStream(new > FileInputStream(f)); > + try (final InputStream fis = new > BufferedInputStream(Files.newInputStream(f.toPath())); > final ArchiveInputStream ais = createArchiveInputStream(args, > fis)) { > System.out.println("Created " + ais.toString()); > ArchiveEntry ae; > @@ -66,4 +66,4 @@ public final class Lister { > System.out.println("Parameters: archive-name [archive-type]"); > } > > -} > \ No newline at end of file > +} > > http://git-wip-us.apache.org/repos/asf/commons-compress/blob/08113862/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java > ---------------------------------------------------------------------- > diff --git > a/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java > > b/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java > index ac4b7bb..7cf95fd 100644 > --- > a/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java > +++ > b/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java > @@ -42,7 +42,7 @@ import org.apache.commons.compress.utils.IOUtils; > * </p> > * <pre> > * CPIOArchiveInputStream cpioIn = new CPIOArchiveInputStream( > - * new FileInputStream(new File("test.cpio"))); > + * Files.newInputStream(Paths.get("test.cpio"))); > * CPIOArchiveEntry cpioEntry; > * > * while ((cpioEntry = cpioIn.getNextEntry()) != null) { > > http://git-wip-us.apache.org/repos/asf/commons-compress/blob/08113862/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java > ---------------------------------------------------------------------- > diff --git > a/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java > > b/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java > index 4f0685b..55da36a 100644 > --- > a/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java > +++ > b/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java > @@ -68,20 +68,20 @@ import org.apache.commons.compress.utils.Sets; > * Example (Compressing a file): > * > * <pre> > - * final OutputStream out = new FileOutputStream(output); > + * final OutputStream out = Files.newOutputStream(output.toPath()); > * CompressorOutputStream cos = new CompressorStreamFactory() > * .createCompressorOutputStream(CompressorStreamFactory.BZIP2, out); > - * IOUtils.copy(new FileInputStream(input), cos); > + * IOUtils.copy(Files.newInputStream(input.toPath()), cos); > * cos.close(); > * </pre> > * > * Example (Decompressing a file): > * > * <pre> > - * final InputStream is = new FileInputStream(input); > + * final InputStream is = Files.newInputStream(input.toPath()); > * CompressorInputStream in = new > CompressorStreamFactory().createCompressorInputStream(CompressorStreamFactory.BZIP2, > * is); > - * IOUtils.copy(in, new FileOutputStream(output)); > + * IOUtils.copy(in, Files.newOutputStream(output.toPath())); > * in.close(); > * </pre> > * > > http://git-wip-us.apache.org/repos/asf/commons-compress/blob/08113862/src/main/java/org/apache/commons/compress/compressors/pack200/TempFileCachingStreamBridge.java > ---------------------------------------------------------------------- > diff --git > a/src/main/java/org/apache/commons/compress/compressors/pack200/TempFileCachingStreamBridge.java > > b/src/main/java/org/apache/commons/compress/compressors/pack200/TempFileCachingStreamBridge.java > index b609b50..dc612aa 100644 > --- > a/src/main/java/org/apache/commons/compress/compressors/pack200/TempFileCachingStreamBridge.java > +++ > b/src/main/java/org/apache/commons/compress/compressors/pack200/TempFileCachingStreamBridge.java > @@ -20,10 +20,10 @@ > package org.apache.commons.compress.compressors.pack200; > > import java.io.File; > -import java.io.FileInputStream; > -import java.io.FileOutputStream; > +import java.io.FilterInputStream; > import java.io.IOException; > import java.io.InputStream; > +import java.nio.file.Files; > > /** > * StreamSwitcher that caches all data written to the output side in > @@ -36,13 +36,13 @@ class TempFileCachingStreamBridge extends StreamBridge { > TempFileCachingStreamBridge() throws IOException { > f = File.createTempFile("commons-compress", "packtemp"); > f.deleteOnExit(); > - out = new FileOutputStream(f); > + out = Files.newOutputStream(f.toPath()); > } > > @Override > InputStream getInputView() throws IOException { > out.close(); > - return new FileInputStream(f) { > + return new FilterInputStream(Files.newInputStream(f.toPath())) { > @Override > public void close() throws IOException { > super.close(); > > http://git-wip-us.apache.org/repos/asf/commons-compress/blob/08113862/src/main/java/org/apache/commons/compress/parallel/FileBasedScatterGatherBackingStore.java > ---------------------------------------------------------------------- > diff --git > a/src/main/java/org/apache/commons/compress/parallel/FileBasedScatterGatherBackingStore.java > > b/src/main/java/org/apache/commons/compress/parallel/FileBasedScatterGatherBackingStore.java > index 1a26d3d..ce6ac07 100644 > --- > a/src/main/java/org/apache/commons/compress/parallel/FileBasedScatterGatherBackingStore.java > +++ > b/src/main/java/org/apache/commons/compress/parallel/FileBasedScatterGatherBackingStore.java > @@ -19,10 +19,10 @@ package org.apache.commons.compress.parallel; > > import java.io.File; > import java.io.FileNotFoundException; > -import java.io.FileInputStream; > -import java.io.FileOutputStream; > import java.io.IOException; > import java.io.InputStream; > +import java.io.OutputStream; > +import java.nio.file.Files; > > /** > * ScatterGatherBackingStore that is backed by a file. > @@ -31,17 +31,24 @@ import java.io.InputStream; > */ > public class FileBasedScatterGatherBackingStore implements > ScatterGatherBackingStore { > private final File target; > - private final FileOutputStream os; > + private final OutputStream os; > private boolean closed; > > public FileBasedScatterGatherBackingStore(final File target) throws > FileNotFoundException { > this.target = target; > - os = new FileOutputStream(target); > + try { > + os = Files.newOutputStream(target.toPath()); > + } catch (FileNotFoundException ex) { > + throw ex; > + } catch (IOException ex) { > + // must convert exception to stay backwards compatible with > Compress 1.10 to 1.13 > + throw new RuntimeException(ex); > + } > } > > @Override > public InputStream getInputStream() throws IOException { > - return new FileInputStream(target); > + return Files.newInputStream(target.toPath()); > } > > @Override > > http://git-wip-us.apache.org/repos/asf/commons-compress/blob/08113862/src/site/xdoc/examples.xml > ---------------------------------------------------------------------- > diff --git a/src/site/xdoc/examples.xml b/src/site/xdoc/examples.xml > index 062b8d3..4d928a8 100644 > --- a/src/site/xdoc/examples.xml > +++ b/src/site/xdoc/examples.xml > @@ -479,9 +479,9 @@ LOOP UNTIL entry.getSize() HAS BEEN READ { > certainly add exception handling and make sure all streams > get closed properly):</p> > <source><![CDATA[ > -FileInputStream fin = new FileInputStream("archive.tar.bz2"); > +InputStream fin = Files.newInputStream(Paths.get("archive.tar.bz2")); > BufferedInputStream in = new BufferedInputStream(fin); > -FileOutputStream out = new FileOutputStream("archive.tar"); > +OutputStream out = Files.newOutputStream(Paths.get("archive.tar")); > BZip2CompressorInputStream bzIn = new BZip2CompressorInputStream(in); > final byte[] buffer = new byte[buffersize]; > int n = 0; > @@ -496,8 +496,8 @@ bzIn.close(); > certainly add exception handling and make sure all streams > get closed properly):</p> > <source><![CDATA[ > -FileInputStream in = new FileInputStream("archive.tar"); > -FileOutputStream fout = new FileOutputStream("archive.tar.gz"); > +InputStream in = Files.newInputStream(Paths.get("archive.tar")); > +OutputStream fout = Files.newOutputStream(Paths.get("archive.tar.gz")); > BufferedOutputStream out = new BufferedInputStream(out); > BZip2CompressorOutputStream bzOut = new BZip2CompressorOutputStream(out); > final byte[] buffer = new byte[buffersize]; > @@ -521,9 +521,9 @@ in.close(); > certainly add exception handling and make sure all streams > get closed properly):</p> > <source><![CDATA[ > -FileInputStream fin = new FileInputStream("archive.tar.gz"); > +InputStream fin = Files.newInputStream(Paths.get("archive.tar.gz")); > BufferedInputStream in = new BufferedInputStream(fin); > -FileOutputStream out = new FileOutputStream("archive.tar"); > +OutputStream out = Files.newOutputStream(Paths.get("archive.tar")); > GZipCompressorInputStream gzIn = new GZipCompressorInputStream(in); > final byte[] buffer = new byte[buffersize]; > int n = 0; > @@ -538,8 +538,8 @@ gzIn.close(); > certainly add exception handling and make sure all streams > get closed properly):</p> > <source><![CDATA[ > -FileInputStream in = new FileInputStream("archive.tar"); > -FileOutputStream fout = new FileOutputStream("archive.tar.gz"); > +InputStream in = Files.newInputStream(Paths.get("archive.tar")); > +OutputStream fout = Files.newOutputStream(Paths.get("archive.tar.gz")); > BufferedOutputStream out = new BufferedInputStream(out); > GZipCompressorOutputStream gzOut = new GZipCompressorOutputStream(out); > final byte[] buffer = new byte[buffersize]; > @@ -566,9 +566,9 @@ in.close(); > certainly add exception handling and make sure all streams > get closed properly):</p> > <source><![CDATA[ > -FileInputStream fin = new FileInputStream("archive.pack"); > +InputStream fin = Files.newInputStream(Paths.get("archive.pack")); > BufferedInputStream in = new BufferedInputStream(fin); > -FileOutputStream out = new FileOutputStream("archive.jar"); > +OutputStream out = Files.newOutputStream(Paths.get("archive.jar")); > Pack200CompressorInputStream pIn = new Pack200CompressorInputStream(in); > final byte[] buffer = new byte[buffersize]; > int n = 0; > @@ -583,8 +583,8 @@ pIn.close(); > certainly add exception handling and make sure all streams > get closed properly):</p> > <source><![CDATA[ > -FileInputStream in = new FileInputStream("archive.jar"); > -FileOutputStream fout = new FileOutputStream("archive.pack"); > +InputStream in = Files.newInputStream(Paths.get("archive.jar")); > +OutputStream fout = Files.newOutputStream(Paths.get("archive.pack")); > BufferedOutputStream out = new BufferedInputStream(out); > Pack200CompressorOutputStream pOut = new Pack200CompressorOutputStream(out); > final byte[] buffer = new byte[buffersize]; > @@ -616,9 +616,9 @@ in.close(); > certainly add exception handling and make sure all streams > get closed properly):</p> > <source><![CDATA[ > -FileInputStream fin = new FileInputStream("archive.tar.xz"); > +InputStream fin = Files.newInputStream(Paths.get("archive.tar.xz")); > BufferedInputStream in = new BufferedInputStream(fin); > -FileOutputStream out = new FileOutputStream("archive.tar"); > +OutputStream out = Files.newOutputStream(Paths.get("archive.tar")); > XZCompressorInputStream xzIn = new XZCompressorInputStream(in); > final byte[] buffer = new byte[buffersize]; > int n = 0; > @@ -633,8 +633,8 @@ xzIn.close(); > certainly add exception handling and make sure all streams > get closed properly):</p> > <source><![CDATA[ > -FileInputStream in = new FileInputStream("archive.tar"); > -FileOutputStream fout = new FileOutputStream("archive.tar.xz"); > +InputStream in = Files.newInputStream(Paths.get("archive.tar")); > +OutputStream fout = Files.newOutputStream(Paths.get("archive.tar.xz")); > BufferedOutputStream out = new BufferedInputStream(out); > XZCompressorOutputStream xzOut = new XZCompressorOutputStream(out); > final byte[] buffer = new byte[buffersize]; > @@ -654,9 +654,9 @@ in.close(); > certainly add exception handling and make sure all streams > get closed properly):</p> > <source><![CDATA[ > -FileInputStream fin = new FileInputStream("archive.tar.Z"); > +InputStream fin = Files.newInputStream(Paths.get("archive.tar.Z")); > BufferedInputStream in = new BufferedInputStream(fin); > -FileOutputStream out = new FileOutputStream("archive.tar"); > +OutputStream out = Files.newOutputStream(Paths.get("archive.tar")); > ZCompressorInputStream zIn = new ZCompressorInputStream(in); > final byte[] buffer = new byte[buffersize]; > int n = 0; > @@ -679,9 +679,9 @@ zIn.close(); > certainly add exception handling and make sure all streams > get closed properly):</p> > <source><![CDATA[ > -FileInputStream fin = new FileInputStream("archive.tar.lzma"); > +InputStream fin = Files.newInputStream(Paths.get("archive.tar.lzma")); > BufferedInputStream in = new BufferedInputStream(fin); > -FileOutputStream out = new FileOutputStream("archive.tar"); > +OutputStream out = Files.newOutputStream(Paths.get("archive.tar")); > LZMACompressorInputStream lzmaIn = new LZMACompressorInputStream(in); > final byte[] buffer = new byte[buffersize]; > int n = 0; > @@ -696,8 +696,8 @@ lzmaIn.close(); > certainly add exception handling and make sure all streams > get closed properly):</p> > <source><![CDATA[ > -FileInputStream in = new FileInputStream("archive.tar"); > -FileOutputStream fout = new FileOutputStream("archive.tar.lzma"); > +InputStream in = Files.newInputStream(Paths.get("archive.tar")); > +OutputStream fout = Files.newOutputStream(Paths.get("archive.tar.lzma")); > BufferedOutputStream out = new BufferedInputStream(out); > LZMACompressorOutputStream lzOut = new LZMACompressorOutputStream(out); > final byte[] buffer = new byte[buffersize]; > @@ -721,9 +721,9 @@ in.close(); > certainly add exception handling and make sure all streams > get closed properly):</p> > <source><![CDATA[ > -FileInputStream fin = new FileInputStream("some-file"); > +InputStream fin = Files.newInputStream(Paths.get("some-file")); > BufferedInputStream in = new BufferedInputStream(fin); > -FileOutputStream out = new FileOutputStream("archive.tar"); > +OutputStream out = Files.newOutputStream(Paths.get("archive.tar")); > DeflateCompressorInputStream defIn = new DeflateCompressorInputStream(in); > final byte[] buffer = new byte[buffersize]; > int n = 0; > @@ -738,8 +738,8 @@ defIn.close(); > certainly add exception handling and make sure all streams > get closed properly):</p> > <source><![CDATA[ > -FileInputStream in = new FileInputStream("archive.tar"); > -FileOutputStream fout = new FileOutputStream("some-file"); > +InputStream in = Files.newInputStream(Paths.get("archive.tar")); > +OutputStream fout = Files.newOutputStream(Paths.get("some-file")); > BufferedOutputStream out = new BufferedInputStream(out); > DeflateCompressorOutputStream defOut = new DeflateCompressorOutputStream(out); > final byte[] buffer = new byte[buffersize]; > @@ -775,9 +775,9 @@ in.close(); > certainly add exception handling and make sure all streams > get closed properly):</p> > <source><![CDATA[ > -FileInputStream fin = new FileInputStream("archive.tar.sz"); > +InputStream fin = Files.newInputStream(Paths.get("archive.tar.sz")); > BufferedInputStream in = new BufferedInputStream(fin); > -FileOutputStream out = new FileOutputStream("archive.tar"); > +OutputStream out = Files.newOutputStream(Paths.get("archive.tar")); > FramedSnappyCompressorInputStream zIn = new > FramedSnappyCompressorInputStream(in); > final byte[] buffer = new byte[buffersize]; > int n = 0; > @@ -792,8 +792,8 @@ zIn.close(); > certainly add exception handling and make sure all streams > get closed properly):</p> > <source><![CDATA[ > -FileInputStream in = new FileInputStream("archive.tar"); > -FileOutputStream fout = new FileOutputStream("archive.tar.sz"); > +InputStream in = Files.newInputStream(Paths.get("archive.tar")); > +OutputStream fout = Files.newOutputStream(Paths.get("archive.tar.sz")); > BufferedOutputStream out = new BufferedInputStream(out); > FramedSnappyCompressorOutputStream snOut = new > FramedSnappyCompressorOutputStream(out); > final byte[] buffer = new byte[buffersize]; > @@ -820,9 +820,9 @@ in.close(); > certainly add exception handling and make sure all streams > get closed properly):</p> > <source><![CDATA[ > -FileInputStream fin = new FileInputStream("archive.tar.lz4"); > +InputStream fin = Files.newInputStream(Paths.get("archive.tar.lz4")); > BufferedInputStream in = new BufferedInputStream(fin); > -FileOutputStream out = new FileOutputStream("archive.tar"); > +OutputStream out = Files.newOutputStream(Paths.get("archive.tar")); > FramedLZ4CompressorInputStream zIn = new FramedLZ4CompressorInputStream(in); > final byte[] buffer = new byte[buffersize]; > int n = 0; > @@ -837,8 +837,8 @@ zIn.close(); > certainly add exception handling and make sure all streams > get closed properly):</p> > <source><![CDATA[ > -FileInputStream in = new FileInputStream("archive.tar"); > -FileOutputStream fout = new FileOutputStream("archive.tar.lz4"); > +InputStream in = Files.newInputStream(Paths.get("archive.tar")); > +OutputStream fout = Files.newOutputStream(Paths.get("archive.tar.lz4")); > BufferedOutputStream out = new BufferedInputStream(out); > FramedLZ4CompressorOutputStream lzOut = new > FramedLZ4CompressorOutputStream(out); > final byte[] buffer = new byte[buffersize]; > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org