Using NIO2 for writing zip file entries without corresponding folder entries
Rafael Winterhalter
rafael.wth at gmail.com
Tue Oct 16 14:48:15 UTC 2018
Yes, this would be an option and I understand that this is a corner-case
but if it can be covered, great. Ideally, one could also choose to have
only certain directories stripped for allowing to retain as much as
possible of the original format.
Thanks for considering this!
Best regards, Rafael
Am Di., 16. Okt. 2018 um 16:22 Uhr schrieb Alan Bateman <
Alan.Bateman at oracle.com>:
> On 16/10/2018 14:00, Rafael Winterhalter wrote:
> > :
> >
> > // Emulate merging two zip files without directories using NIO2
> > try (
> > FileSystem source = FileSystems.newFileSystem(sample, null);
> > FileSystem target = FileSystems.newFileSystem(other, null)
> > ) {
> > Path path = source.getPath("foo/bar.txt");
> > Files.copy(path, target.getPath(source.toString()));
> > }
> >
> > It surprised me that this does not work when trying to migrate from
> > ZipInputStream to NIO2.
> If I read this correctly, it is attempting to copy foo/bar.txt from one
> file system to a non-existent directory in the other file system. As I
> said, the zip file system tries to behave like a regular file system so
> it is correct to fail when the directory doesn't exist. I think the only
> thing we can do here is introduce a configuration option to strip
> directories when writing, it's just something that hasn't come up before.
>
> -Alan
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20181016/8820991d/attachment.html>
More information about the nio-dev
mailing list