Unable to create a zip file using the Zip filesystem provider anymore?
Xueming Shen
xueming.shen at oracle.com
Fri Apr 29 16:33:01 UTC 2016
On 4/29/16 9:13 AM, Francis Galiegue wrote:
> Hello,
>
> On Fri, Apr 29, 2016 at 6:06 PM, Xueming Shen <xueming.shen at oracle.com> wrote:
>> I doubt it ever worked this way. The code created a zero-length empty file
>> which is not in zip format ...
>> The "create" is only checked if the file does not exits.
>>
> This page disagrees:
What do you mean "disagrees"? The note says "create a new zip file if it
does not exist". In your test
case the temp file is created via Files.createTempFile(), so for zipfs
the file exists but it is not in
zip format.
The JDK7 code looks like (the source is in demo)
// configurable env setup
this.createNew = "true".equals(env.get("create"));
...
this.provider = provider;
this.zfpath = zfpath;
if (Files.notExists(zfpath)) {
if (createNew) {
try (OutputStream os = Files.newOutputStream(zfpath,
CREATE_NEW, WRITE)) {
new END().write(os, 0);
}
} else {
throw new FileSystemNotFoundException(zfpath.toString());
}
It appears it behaves this way from the very beginning, at least from
the official release. I did not
check the history to see if it ever worked way you would like to see in
some beta releases though :-)
Sherman
> http://docs.oracle.com/javase/7/docs/technotes/guides/io/fsp/zipfilesystemprovider.html
>
> Note the link it points to:
>
> http://docs.oracle.com/javase/7/docs/technotes/guides/io/fsp/zipfilesystemproviderprops.html
>
> Quoting:
>
> create true / false The value should be of type java.lang.String. The
> default value is false. If the value is true, the zip file system
> provider creates a new zip file if it does not exist.
>
> I did try that in the past and it _did_ work. Now it doesn't work anymore.
>
> The problem is, I can't tell since which version it doesn't work anymore :(
More information about the nio-dev
mailing list