Zip file system provider only works with default file system
philippe.marschall at gmail.com
Sun Dec 9 07:08:59 PST 2012
On Sat, Dec 8, 2012 at 9:18 PM, Michael Hall <mik3hall at gmail.com> wrote:
> It's a demo.
> Couldn't you just temporarily put your own ZipFileSystem in classpath some
> place before the default version jar?
Well, since zipfs.jar is part of the JRE that would probably have go
to do endorsed/ not the nicest place to be.
> With something like…
> In com.sun.nio.zipfs.ZipFileSystem
> // Creates a new empty temporary file in the same directory as the
> // specified file. A variant of File.createTempFile.
> private Path createTempFileInSameDirectoryAs(Path path)
> throws IOException
> Path parent = path.toAbsolutePath().getParent();
> Path tmpPath = Files.createTempFile(dir,"zipfstmp", null);
> return tmpPath;
> Assumes it'll use the correct FileSystem as the parameter's Path all the way
> through, I haven't tested it at all.
> Not sure if there are any complications with a com.sun class. You could
> change the demo package.
> Are you just trying this out or do you intend to use the demo code in
> something production?
The plan is to use it in testing, like an in-memory database (JavaDB,
…). Especially interesting would be that you can simulate a
Linux/Windows/Mac file system on a developer workstation without
having to run the tests on a slave. It would also be cool if you could
initialize a file system from a ZIP file and drop the contents of the
file system into a ZIP file for analysis if the test fails. And
sometimes you just want to create an in-memory zip, eg. in a servlet.
More information about the nio-dev