Java Path Create nio createZipFileSystem(Path path)

Here you can find the source of createZipFileSystem(Path path)

Description

Create a zip file system and returns back the root

License

Open Source License

Parameter

Parameter Description
path the path to the file

Exception

Parameter Description
IOException an exception

Return

the root of the new file system

Declaration

public static Path createZipFileSystem(Path path) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;

import java.net.URI;

import java.nio.file.FileSystem;
import java.nio.file.FileSystems;

import java.nio.file.Files;
import java.nio.file.Path;

import java.util.HashMap;

import java.util.Map;

public class Main {
    /**/*from   w  ww . j a  v a2s  .  c  om*/
     * Create a zip file system and returns back the root
     *
     * @param path the path to the file
     * @return the root of the new file system
     * @throws IOException
     */
    public static Path createZipFileSystem(Path path) throws IOException {
        Map<String, String> env = new HashMap<>();
        if (!Files.exists(path)) {
            env.put("create", "true");
        }
        URI uri = URI.create("jar:file:" + path.toUri().getPath());
        FileSystem fileSystem = FileSystems.newFileSystem(uri, env, null);
        return fileSystem.getPath("/");
    }
}

Related

  1. createTmpDir(Path tmpDir, String prefix)
  2. createUniqueFilePath(final String directory, final String baseName, final String suffix)
  3. createUrlQuietly(Path path)
  4. createZipArchive(final Path sourceDir, final Path destFile)
  5. createZipFile(final File pathToArchive)
  6. createZipFileSystem(Path zipFile)
  7. createZipFs(Path path)
  8. createZkNodeName(String zkRoot, Path root, Path file)
  9. getOrCreateDir(Path path)