jdk/src/share/demo/nio/zipfs/README.txt
changeset 23977 cb2cf6e2958a
parent 23976 16ec7c58cdea
parent 23964 65b2502dbd2d
child 23978 8c0bdeecd7c0
equal deleted inserted replaced
23976:16ec7c58cdea 23977:cb2cf6e2958a
     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