Unable to create a zip file using the Zip filesystem provider anymore?
Xueming Shen
xueming.shen at oracle.com
Fri Apr 29 17:05:29 UTC 2016
On 04/29/2016 09:59 AM, Francis Galiegue wrote:
>
> public final class Foo
> {
> private static final Path ZIP = Paths.get("/tmp/t.zip");
>
> private static final String ENTRY = "foo";
>
> private Foo()
> {
> throw new Error("instantiation not permitted");
> }
>
> public static void main(final String... args)
> throws IOException
> {
> Files.deleteIfExists(ZIP);
> Files.createFile(ZIP);
>
Why do you need to create an empty file? an empty is not an empty zip file.
An empty zip file need to have at least a "END" table.
> final URI uri = URI.create("jar:" + ZIP.toUri());
>
> try (
> final FileSystem fs = FileSystems.newFileSystem(uri,
> Collections.singletonMap("create", true));
true -> "true"
> ) {
> final Path entry = fs.getPath(ENTRY);
+ Files.createFile(entry);
then it should work.
-sherman
More information about the nio-dev
mailing list