-
Notifications
You must be signed in to change notification settings - Fork 199
Should I call flush before closing when using ZstdOutputStream? #335
Copy link
Copy link
Closed
Description
Hopefully, someone could help on whether we should call flush before closing a ZstdOuputStream? Because this could produce different behavior.
// compress without flush
byte[] bytes1 = null;
ByteArrayOutputStream outputStream1 = new ByteArrayOutputStream();
try(ByteArrayOutputStream out = outputStream1;
ZstdOutputStream zstd = new ZstdOutputStream(out, 3)) {
zstd.setWorkers(0);
zstd.write(0);
}
bytes1 = outputStream1.toByteArray();
// compress with flush
byte[] bytes2 = null;
ByteArrayOutputStream outputStream2 = new ByteArrayOutputStream();
try(ByteArrayOutputStream out = outputStream2;
ZstdOutputStream zstd = new ZstdOutputStream(out, 3)) {
zstd.setWorkers(0);
zstd.write(0);
zstd.flush(); // flush before close
}
bytes2 = outputStream2.toByteArray();
Arrays.equals(bytes1, bytes2);Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
