How to get 'java.io.IOException No space left on device' using ZipFileSystem

2k Views Asked by At

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?

0

There are 0 best solutions below