jdk/src/share/demo/nio/zipfs/README.txt
changeset 24414 2061862eb57c
parent 24413 1d117d2dfe92
parent 24077 0809c9a4d36e
child 24415 43aa54df554d
equal deleted inserted replaced
24413:1d117d2dfe92 24414:2061862eb57c
     1 ZipFileSystem is a file system provider that treats the contents of a zip or
       
     2 JAR file as a java.nio.file.FileSystem.
       
     3 
       
     4 The factory methods defined by the java.nio.file.FileSystems class can be
       
     5 used to create a FileSystem, eg:
       
     6 
       
     7    // use file type detection
       
     8    Path jarfile = Paths.get("foo.jar");
       
     9    FileSystem fs = FileSystems.newFileSystem(jarfile, null);
       
    10 
       
    11 -or
       
    12 
       
    13    // locate file system by the legacy JAR URL syntax
       
    14    Map<String,?> env = Collections.emptyMap();
       
    15    URI uri = URI.create("jar:file:/mydir/foo.jar");
       
    16    FileSystem fs = FileSystems.newFileSystem(uri, env);
       
    17 
       
    18 Once a FileSystem is created then classes in the java.nio.file package
       
    19 can be used to access files in the zip/JAR file, eg:
       
    20 
       
    21    Path mf = fs.getPath("/META-INF/MANIFEST.MF");
       
    22    InputStream in = mf.newInputStream();
       
    23 
       
    24 See Demo.java for more interesting usages.
       
    25 
       
    26