當前位置: 首頁>>代碼示例>>Java>>正文


Java FileSystemNotFoundException類代碼示例

本文整理匯總了Java中java.nio.file.FileSystemNotFoundException的典型用法代碼示例。如果您正苦於以下問題:Java FileSystemNotFoundException類的具體用法?Java FileSystemNotFoundException怎麽用?Java FileSystemNotFoundException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FileSystemNotFoundException類屬於java.nio.file包,在下文中一共展示了FileSystemNotFoundException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: create

import java.nio.file.FileSystemNotFoundException; //導入依賴的package包/類
public static Path create( URI uri )
{
  try
  {
    return Paths.get( uri );
  }
  catch( FileSystemNotFoundException nfe )
  {
    try
    {
      Map<String, String> env = new HashMap<>();
      env.put( "create", "true" ); // creates zip/jar file if not already exists
      FileSystem fs = FileSystems.newFileSystem( uri, env );
      return fs.provider().getPath( uri );
    }
    catch( IOException e )
    {
      throw new RuntimeException( e );
    }
  }
}
 
開發者ID:manifold-systems,項目名稱:manifold,代碼行數:22,代碼來源:PathUtil.java

示例2: listFiles

import java.nio.file.FileSystemNotFoundException; //導入依賴的package包/類
public List<Path> listFiles(Path dirPath)
{
    List<Path> files = new ArrayList<>();
    if (!getFS().isPresent()) {
        throw new FileSystemNotFoundException("");
    }
    FileStatus[] fileStatuses = new FileStatus[0];
    try {
        fileStatuses = getFS().get().listStatus(dirPath);
    }
    catch (IOException e) {
        log.error(e);
    }
    for (FileStatus f : fileStatuses) {
        if (f.isFile()) {
            files.add(f.getPath());
        }
    }
    return files;
}
 
開發者ID:dbiir,項目名稱:paraflow,代碼行數:21,代碼來源:FSFactory.java

示例3: open

import java.nio.file.FileSystemNotFoundException; //導入依賴的package包/類
static SystemImage open() throws IOException {
    if (modulesImageExists) {
        // open a .jimage and build directory structure
        final ImageReader image = ImageReader.open(moduleImageFile);
        image.getRootDirectory();
        return new SystemImage() {
            @Override
            Node findNode(String path) throws IOException {
                return image.findNode(path);
            }
            @Override
            byte[] getResource(Node node) throws IOException {
                return image.getResource(node);
            }
            @Override
            void close() throws IOException {
                image.close();
            }
        };
    }
    if (Files.notExists(explodedModulesDir))
        throw new FileSystemNotFoundException(explodedModulesDir.toString());
    return new ExplodedImage(explodedModulesDir);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:SystemImage.java

示例4: getFileSystem

import java.nio.file.FileSystemNotFoundException; //導入依賴的package包/類
/**
 * Retrieves a file system using the default {@link FileSystems#getFileSystem(URI)}. If this
 * throws a 
 * @param uri
 * @return
 */
public static FileSystem getFileSystem(URI uri) {
	try {
		return FileSystems.getFileSystem(uri);
	} catch (FileSystemNotFoundException | ProviderNotFoundException e) {
		LOG.debug("File system scheme " + uri.getScheme() +
				" not found in the default installed providers list, attempting to find this in the "
				+ "list of additional providers");
	}

	for (WeakReference<FileSystemProvider> providerRef : providers) {
		FileSystemProvider provider = providerRef.get();
		
		if (provider != null && uri.getScheme().equals(provider.getScheme())) {
			return provider.getFileSystem(uri);
		}
	}
	
	throw new ProviderNotFoundException("Could not find provider for scheme '" + uri.getScheme() + "'");
}
 
開發者ID:brdara,項目名稱:java-cloud-filesystem-provider,代碼行數:26,代碼來源:FileSystemProviderHelper.java

示例5: createDetectorsRepo

import java.nio.file.FileSystemNotFoundException; //導入依賴的package包/類
static Repository createDetectorsRepo(Class<?> clazz, String pluginName, Set<Path> paths) {
    CodeSource codeSource = clazz.getProtectionDomain().getCodeSource();
    if (codeSource == null) {
        throw new RuntimeException(format("Initializing plugin '%s' could not get code source for class %s", pluginName, clazz.getName()));
    }

    URL url = codeSource.getLocation();
    try {
        Path path = Paths.get(url.toURI());
        if(paths.add(path)) {
            if(Files.isDirectory(path)) {
                return new DirRepository(path);
            } else {
                return new JarRepository(new JarFile(path.toFile()));
            }
        } else {
            return createNullRepository();
        }
    } catch (URISyntaxException | FileSystemNotFoundException | IllegalArgumentException
            | IOException | UnsupportedOperationException e) {
        String errorMessage = format("Error creating detector repository for plugin '%s'", pluginName);
        throw new RuntimeException(errorMessage, e);
    }
}
 
開發者ID:amaembo,項目名稱:huntbugs,代碼行數:25,代碼來源:Repository.java

示例6: getInformation

import java.nio.file.FileSystemNotFoundException; //導入依賴的package包/類
public MCRIIIFImageInformation getInformation(String identifier)
    throws MCRIIIFImageNotFoundException, MCRIIIFImageProvidingException, MCRAccessException {
    try {
        Path tiledFile = tileFileProvider.getTiledFile(identifier);
        MCRTiledPictureProps tiledPictureProps = getTiledPictureProps(tiledFile);

        MCRIIIFImageInformation imageInformation = new MCRIIIFImageInformation(MCRIIIFBase.API_IMAGE_2,
            buildURL(identifier), DEFAULT_PROTOCOL, tiledPictureProps.getWidth(), tiledPictureProps.getHeight());

        MCRIIIFImageTileInformation tileInformation = new MCRIIIFImageTileInformation(256, 256);
        for (int i = 0; i < tiledPictureProps.getZoomlevel(); i++) {
            tileInformation.scaleFactors.add((int) Math.pow(2, i));
        }

        imageInformation.tiles.add(tileInformation);

        return imageInformation;
    } catch (FileSystemNotFoundException e) {
        LOGGER.error("Could not find Iview ZIP for {}", identifier, e);
        throw new MCRIIIFImageNotFoundException(identifier);
    }
}
 
開發者ID:MyCoRe-Org,項目名稱:mycore,代碼行數:23,代碼來源:MCRIVIEWIIIFImageImpl.java

示例7: getFileSystem

import java.nio.file.FileSystemNotFoundException; //導入依賴的package包/類
public static FileSystem getFileSystem(Path iviewFile) throws IOException {
    URI uri = URI.create("jar:" + iviewFile.toUri());
    try {
        return FileSystems.newFileSystem(uri, Collections.emptyMap(),
            MCRIView2Tools.class.getClassLoader());
    } catch (FileSystemAlreadyExistsException exc) {
        // block until file system is closed
        try {
            FileSystem fileSystem = FileSystems.getFileSystem(uri);
            while (fileSystem.isOpen()) {
                try {
                    Thread.sleep(10);
                } catch (InterruptedException ie) {
                    // get out of here
                    throw new IOException(ie);
                }
            }
        } catch (FileSystemNotFoundException fsnfe) {
            // seems closed now -> do nothing and try to return the file system again
            LOGGER.debug("Filesystem not found", fsnfe);
        }
        return getFileSystem(iviewFile);
    }
}
 
開發者ID:MyCoRe-Org,項目名稱:mycore,代碼行數:25,代碼來源:MCRIView2Tools.java

示例8: getInstance

import java.nio.file.FileSystemNotFoundException; //導入依賴的package包/類
/**
 * Returns any subclass that implements and handles the given scheme.
 * @param scheme a valid {@link URI} scheme
 * @see FileSystemProvider#getScheme()
 * @throws FileSystemNotFoundException if no filesystem handles this scheme
 */
public static MCRAbstractFileSystem getInstance(String scheme) {
    URI uri;
    try {
        uri = MCRPaths.getURI(scheme, "helper", SEPARATOR_STRING);
    } catch (URISyntaxException e) {
        throw new MCRException(e);
    }
    for (FileSystemProvider provider : Iterables.concat(MCRPaths.webAppProvider,
        FileSystemProvider.installedProviders())) {
        if (provider.getScheme().equals(scheme)) {
            return (MCRAbstractFileSystem) provider.getFileSystem(uri);
        }
    }
    throw new FileSystemNotFoundException("Provider \"" + scheme + "\" not found");
}
 
開發者ID:MyCoRe-Org,項目名稱:mycore,代碼行數:22,代碼來源:MCRAbstractFileSystem.java

示例9: getPath

import java.nio.file.FileSystemNotFoundException; //導入依賴的package包/類
@Override
public Path getPath(final URI uri) {
    if (!FS_URI.getScheme().equals(Objects.requireNonNull(uri).getScheme())) {
        throw new FileSystemNotFoundException("Unkown filesystem: " + uri);
    }
    String path = uri.getPath().substring(1);//URI path is absolute -> remove first slash
    String owner = null;
    for (int i = 0; i < path.length(); i++) {
        if (path.charAt(i) == MCRAbstractFileSystem.SEPARATOR) {
            break;
        }
        if (path.charAt(i) == ':') {
            owner = path.substring(0, i);
            path = path.substring(i + 1);
            break;
        }

    }
    return MCRAbstractFileSystem.getPath(owner, path, getFileSystemFromPathURI(FS_URI));
}
 
開發者ID:MyCoRe-Org,項目名稱:mycore,代碼行數:21,代碼來源:MCRFileSystemProvider.java

示例10: getLocalSystem

import java.nio.file.FileSystemNotFoundException; //導入依賴的package包/類
private JFileSystem getLocalSystem()
{
  synchronized (_localSystem) {
    JFileSystem localSystem = _localSystem.getLevel();
    
    if (localSystem == null) {
      BartenderFileSystem fileSystem = BartenderFileSystem.getCurrent();

      if (fileSystem == null) {
        throw new FileSystemNotFoundException(L.l("cannot find local bfs file system"));
      }

      ServiceRef root = fileSystem.getRootServiceRef();

      localSystem = new JFileSystem(this, root);
      
      _localSystem.set(localSystem);
    }
    
    return localSystem;
  }
}
 
開發者ID:baratine,項目名稱:baratine,代碼行數:23,代碼來源:JFileSystemProvider.java

示例11: getPomPath

import java.nio.file.FileSystemNotFoundException; //導入依賴的package包/類
private Path getPomPath() throws URISyntaxException {
    try {
        String className = getClass().getName();
        String classfileName = "/" + className.replace('.', '/') + ".class";
        URL classfileResource = getClass().getResource(classfileName);
        if (classfileResource != null) {
            Path absolutePackagePath = Paths.get(classfileResource.toURI())
                    .getParent();
            int packagePathSegments = className.length()
                    - className.replace(".", "").length();
            Path path = absolutePackagePath;
            for (int i = 0, segmentsToRemove = packagePathSegments + 2;
                 i < segmentsToRemove; i++) {
                path = path.getParent();
            }
            return path.resolve("pom.xml");
        }
    } catch (FileSystemNotFoundException e) {
        log.log(Level.INFO,
                "Not in Filesystem-Mode: "
                        + e.getMessage(), e);
    }
    return null;
}
 
開發者ID:gdi-by,項目名稱:downloadclient,代碼行數:25,代碼來源:Info.java

示例12: getFileSystem

import java.nio.file.FileSystemNotFoundException; //導入依賴的package包/類
@Override
public BundleFileSystem getFileSystem(URI uri) {
	synchronized (openFilesystems) {
		URI baseURI = baseURIFor(uri);
		WeakReference<BundleFileSystem> ref = openFilesystems.get(baseURI);
		if (ref == null) {
			throw new FileSystemNotFoundException(uri.toString());
		}
		BundleFileSystem fs = ref.get();
		if (fs == null) {
			openFilesystems.remove(baseURI);
			throw new FileSystemNotFoundException(uri.toString());
		}
		return fs;
	}
}
 
開發者ID:apache,項目名稱:incubator-taverna-language,代碼行數:17,代碼來源:BundleFileSystemProvider.java

示例13: AbstractTarFileSystem

import java.nio.file.FileSystemNotFoundException; //導入依賴的package包/類
protected AbstractTarFileSystem(AbstractTarFileSystemProvider provider,
		Path tfpath, Map<String, ?> env) throws IOException {
	// configurable env setup
	createNew = "true".equals(env.get("create"));
	defaultDir = env.containsKey("default.dir") ? (String) env
			.get("default.dir") : "/";
	entriesToData = new HashMap<>();
	if (defaultDir.charAt(0) != '/') {
		throw new IllegalArgumentException("default dir should be absolute");
	}
	this.provider = provider;
	this.tfpath = tfpath;
	if (Files.notExists(tfpath)) {
		if (!createNew) {
			throw new FileSystemNotFoundException(tfpath.toString());
		}
	}
	// sm and existence check
	tfpath.getFileSystem().provider().checkAccess(tfpath, AccessMode.READ);
	if (!Files.isWritable(tfpath)) {
		readOnly = true;
	}
	defaultdir = new TarPath(this, defaultDir.getBytes());
	outputStreams = new ArrayList<>();
	mapEntries();
}
 
開發者ID:PeterLaker,項目名稱:archive-fs,代碼行數:27,代碼來源:AbstractTarFileSystem.java

示例14: getFileSystem

import java.nio.file.FileSystemNotFoundException; //導入依賴的package包/類
public FileSystem getFileSystem( URI uri ) {
    checkURI( uri );

    String id = uriMapper.getSchemeSpecificPart( uri );

    FileSystem ret = fileSystems.get( id );

    if( ret == null ) {
        throw new FileSystemNotFoundException( uri.toString() );
    }

    if( !ret.isOpen() ) {
        fileSystems.remove( id ); // for GC
        throw new FileSystemNotFoundException( uri.toString() );
    }

    return ret;
}
 
開發者ID:openCage,項目名稱:eightyfs,代碼行數:19,代碼來源:ProviderURIStuff.java

示例15: asPath

import java.nio.file.FileSystemNotFoundException; //導入依賴的package包/類
/**
 * Convert the given path {@link URI} to a {@link Path} object.
 * @param uri the path to convert
 * @return a {@link Path} object
 */
public static Path asPath(URI uri) {
  try {
    return Paths.get(uri);
  } catch (FileSystemNotFoundException e) {
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    if (cl == null) {
      throw e;
    }
    try {
      return FileSystems.newFileSystem(uri, new HashMap<>(), cl).provider().getPath(uri);
    } catch (IOException ex) {
      throw new RuntimeException("Cannot create filesystem for " + uri, ex);
    }
  }
}
 
開發者ID:HadoopGenomics,項目名稱:Hadoop-BAM,代碼行數:21,代碼來源:NIOFileUtil.java


注:本文中的java.nio.file.FileSystemNotFoundException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。