Go back to previous way of creating new streams
@@ -119,40 +119,35 @@ public class FileReferenceCompressor {
}
private OutputStream compressedOutputStream(File outputFile) throws IOException {
- FileOutputStream out = new FileOutputStream(outputFile);
switch (type) {
case compressed:
log.log(Level.FINE, () -> "Compressing with compression type " + compressionType);
return switch (compressionType) {
- case gzip -> new GZIPOutputStream(out);
- case lz4 -> new LZ4BlockOutputStream(out);
- case zstd -> new ZstdOutputStream(out);
+ case gzip -> new GZIPOutputStream(new FileOutputStream(outputFile));
+ case lz4 -> new LZ4BlockOutputStream(new FileOutputStream(outputFile));
+ case zstd -> new ZstdOutputStream(new FileOutputStream(outputFile));
};
case file:
- return out;
+ return new FileOutputStream(outputFile);
default:
- out.close();
throw new RuntimeException("Unknown file reference type " + type);
}
}
private InputStream decompressedInputStream(File inputFile) throws IOException {
- FileInputStream in = new FileInputStream(inputFile);
switch (type) {
case compressed:
log.log(Level.FINE, () -> "Decompressing with compression type " + compressionType);
return switch (compressionType) {
- case gzip -> new GZIPInputStream(in);
- case lz4 -> new LZ4BlockInputStream(in);
- case zstd -> new ZstdInputStream(in);
+ case gzip -> new GZIPInputStream(new FileInputStream(inputFile));
+ case lz4 -> new LZ4BlockInputStream(new FileInputStream(inputFile));
+ case zstd -> new ZstdInputStream(new FileInputStream(inputFile));
};
case file:
- return in;
+ return new FileInputStream(inputFile);
default:
- in.close();
throw new RuntimeException("Unknown file reference type " + type);
}
}
}
-
