I save several files in a zip file using Java's FileSystem. If there is not enough disk space I can not get java.io.IOException No space left on device
and it behaves as if the zip file were created successfully.
Here is a snippet from my project:
Path pathToZip = Paths.get("path/to/existing/zip");
try(FileSystem fs = FileSystems.newFileSystem(pathToZip, null)) {
// zip some files via
Path pathToSomeFile = Paths.get("path/of/some/file/to/be/zipped");
Files.copy(pathToSomeFile, fs.getPath("/path/of/some/file/to/be/zipped"));
} catch (IOException ex) {
log.error("error on zipping files", ex);
}
The FileSystems.newFileSystem(pathToZip, null)
creates a ZipFileSystem
instance. I've debugged up to the method sync()
of the class ZipFileSystem
. Then, when the java.io.IOException No space left on device
occurs, only x.printStackTrace()
is called and the exception is gone.
What options do I have to see if the file was successfully written?