Package java.nio.file.spi

Examples of java.nio.file.spi.FileSystemProvider


            return provider.getFileSystem(URI.create("file:///"));
        }

        // returns default provider
        private static FileSystemProvider getDefaultProvider() {
            FileSystemProvider provider = sun.nio.fs.DefaultFileSystemProvider.create();

            // if the property java.nio.file.spi.DefaultFileSystemProvider is
            // set then its value is the name of the default provider (or a list)
            String propValue = System
                .getProperty("java.nio.file.spi.DefaultFileSystemProvider");
            if (propValue != null) {
                for (String cn: propValue.split(",")) {
                    try {
                        Class<?> c = Class
                            .forName(cn, true, ClassLoader.getSystemClassLoader());
                        Constructor<?> ctor = c
                            .getDeclaredConstructor(FileSystemProvider.class);
                        provider = (FileSystemProvider)ctor.newInstance(provider);

                        // must be "file"
                        if (!provider.getScheme().equals("file"))
                            throw new Error("Default provider must use scheme 'file'");

                    } catch (Exception x) {
                        throw new Error(x);
                    }
View Full Code Here


     *          LinkPermission}{@code ("symbolic")}.
     */
    public static Path copy(Path source, Path target, CopyOption... options)
        throws IOException
    {
        FileSystemProvider provider = provider(source);
        if (provider(target) == provider) {
            // same provider
            provider.copy(source, target, options);
        } else {
            // different providers
            CopyMoveHelper.copyToForeignTarget(source, target, options);
        }
        return target;
View Full Code Here

     *          target file.
     */
    public static Path move(Path source, Path target, CopyOption... options)
        throws IOException
    {
        FileSystemProvider provider = provider(source);
        if (provider(target) == provider) {
            // same provider
            provider.move(source, target, options);
        } else {
            // different providers
            CopyMoveHelper.moveToForeignTarget(source, target, options);
        }
        return target;
View Full Code Here

     *          LinkPermission}{@code ("symbolic")}.
     */
    public static Path copy(Path source, Path target, CopyOption... options)
        throws IOException
    {
        FileSystemProvider provider = provider(source);
        if (provider(target) == provider) {
            // same provider
            provider.copy(source, target, options);
        } else {
            // different providers
            CopyMoveHelper.copyToForeignTarget(source, target, options);
        }
        return target;
View Full Code Here

     *          target file.
     */
    public static Path move(Path source, Path target, CopyOption... options)
        throws IOException
    {
        FileSystemProvider provider = provider(source);
        if (provider(target) == provider) {
            // same provider
            provider.move(source, target, options);
        } else {
            // different providers
            CopyMoveHelper.moveToForeignTarget(source, target, options);
        }
        return target;
View Full Code Here

        static final FileSystem defaultFileSystem = defaultFileSystem();

        // returns default file system
        private static FileSystem defaultFileSystem() {
            // load default provider
            FileSystemProvider provider = AccessController
                .doPrivileged(new PrivilegedAction<FileSystemProvider>() {
                    public FileSystemProvider run() {
                        return getDefaultProvider();
                    }
                });

            // return file system
            return provider.getFileSystem(URI.create("file:///"));
        }
View Full Code Here

            return provider.getFileSystem(URI.create("file:///"));
        }

        // returns default provider
        private static FileSystemProvider getDefaultProvider() {
            FileSystemProvider provider = sun.nio.fs.DefaultFileSystemProvider.create();

            // if the property java.nio.file.spi.DefaultFileSystemProvider is
            // set then its value is the name of the default provider (or a list)
            String propValue = System
                .getProperty("java.nio.file.spi.DefaultFileSystemProvider");
            if (propValue != null) {
                for (String cn: propValue.split(",")) {
                    try {
                        Class<?> c = Class
                            .forName(cn, true, ClassLoader.getSystemClassLoader());
                        Constructor<?> ctor = c
                            .getDeclaredConstructor(FileSystemProvider.class);
                        provider = (FileSystemProvider)ctor.newInstance(provider);

                        // must be "file"
                        if (!provider.getScheme().equals("file"))
                            throw new Error("Default provider must use scheme 'file'");

                    } catch (Exception x) {
                        throw new Error(x);
                    }
View Full Code Here

    assertFalse(fs.isOpen());
  }

  @Test
  public void testIsNotAvailableFromProvider() throws IOException {
    FileSystemProvider provider = fs.provider();
    URI uri = fs.getUri();
    assertEquals(fs, provider.getFileSystem(uri));

    fs.close();

    try {
      provider.getFileSystem(uri);
      fail();
    } catch (FileSystemNotFoundException expected) {
    }
  }
View Full Code Here

        // 8. Create a new ServiceLoader instance with the URLClassLoader, and call load on the interface.
        ServletContext context = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
        Path webInfLibDirectory = Paths.get(context.getRealPath("WEB-INF/lib"));
        URLClassLoader urlcl;
        List<URL> jarURLs = new ArrayList<>();
        FileSystemProvider provider = getZipFileSystemProvider();
        List<String> implementationsToLoad = new ArrayList<>();

        if (Files.exists(webInfLibDirectory, LinkOption.NOFOLLOW_LINKS)) {
            List<Path> files = listJars(webInfLibDirectory);

            for (Path p : files) {
                info("LOCATED JAR " + p.toFile().getName());
                jarURLs.add(p.toUri().toURL());
                FileSystem fs = provider.newFileSystem(p, new HashMap<String, Object>());
                Path serviceDirectory = fs.getPath("/META-INF", "services");
                info("SCANNING SERVICES");

                if (Files.exists(serviceDirectory)) {
                    DirectoryStream<Path> serviceListings = Files.newDirectoryStream(serviceDirectory);
View Full Code Here

            globalStore.writeTo(out);
        }
    }

    private void writeChunkStores() throws IOException {
        FileSystemProvider zipProvider = getZipFileSystemProvider();

        Path chunksPath =  storagePathProvider.getWorldTempPath();
        Files.createDirectories(chunksPath);
        if (storeChunksInZips) {
            Map<Vector3i, FileSystem> newChunkZips = Maps.newHashMap();
            for (Map.Entry<Vector3i, CompressedChunkBuilder> entry : compressedChunkBuilders.entrySet()) {
                Vector3i chunkPos = entry.getKey();
                Vector3i chunkZipPos = storagePathProvider.getChunkZipPosition(chunkPos);
                FileSystem zip = newChunkZips.get(chunkZipPos);
                if (zip == null) {
                    Path targetPath = storagePathProvider.getChunkZipTempPath(chunkZipPos);
                    Files.deleteIfExists(targetPath);
                    zip = zipProvider.newFileSystem(targetPath, CREATE_ZIP_OPTIONS);
                    newChunkZips.put(chunkZipPos, zip);
                }
                Path chunkPath = zip.getPath(storagePathProvider.getChunkFilename(chunkPos));
                CompressedChunkBuilder compressedChunkBuilder = entry.getValue();
                byte[] compressedChunk = compressedChunkBuilder.buildEncodedChunk();
View Full Code Here

TOP

Related Classes of java.nio.file.spi.FileSystemProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.