• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FileSystemAlreadyExistsException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中java.nio.file.FileSystemAlreadyExistsException的典型用法代码示例。如果您正苦于以下问题:Java FileSystemAlreadyExistsException类的具体用法?Java FileSystemAlreadyExistsException怎么用?Java FileSystemAlreadyExistsException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FileSystemAlreadyExistsException类属于java.nio.file包,在下文中一共展示了FileSystemAlreadyExistsException类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: newFileSystem

import java.nio.file.FileSystemAlreadyExistsException; //导入依赖的package包/类
@Override
public FileSystem newFileSystem(Path fakeRoot, Map<String,?> env)
    throws IOException
{
    if (env != null && env.keySet().contains("IOException")) {
        triggerEx("IOException");
    }

    synchronized (FaultyFSProvider.class) {
        if (delegate != null && delegate.isOpen())
            throw new FileSystemAlreadyExistsException();
        FaultyFileSystem result = new FaultyFileSystem(fakeRoot);
        delegate = result;
        return result;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:FaultyFileSystem.java


示例2: getFileSystem

import java.nio.file.FileSystemAlreadyExistsException; //导入依赖的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


示例3: listResources

import java.nio.file.FileSystemAlreadyExistsException; //导入依赖的package包/类
/**
 * Lists all children resources.
 *
 * @param parent the root path represented in {@link URI} format
 * @param consumer consumer for children resources
 * @throws java.io.IOException if any i/o error occur
 * @throws ProviderNotFoundException if a provider supporting the URI scheme is not installed
 */
public static void listResources(URI parent, Consumer<Path> consumer) throws IOException {
  FileSystem fileSystem = null;
  try {
    if (!"file".equals(parent.getScheme())) {
      try {
        fileSystem = FileSystems.newFileSystem(parent, Collections.emptyMap());
      } catch (FileSystemAlreadyExistsException ignore) {
      }
    }

    Path root = Paths.get(parent);
    Files.list(root).forEach(consumer);
  } finally {
    // close FS only if only it has been initialized here
    if (fileSystem != null) {
      fileSystem.close();
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:28,代码来源:IoUtil.java


示例4: newFileSystem

import java.nio.file.FileSystemAlreadyExistsException; //导入依赖的package包/类
@Override
public FileSystem newFileSystem(URI uri, Map<String, ?> env)
		throws IOException {
	Path path = uriToPath(uri);
	synchronized (filesystems) {
		Path realPath = null;
		if (ensureFile(path)) {
			realPath = path.toRealPath();
			if (filesystems.containsKey(realPath)) {
				throw new FileSystemAlreadyExistsException();
			}
		}
		AbstractTarFileSystem tarfs = null;
		tarfs = newInstance(this, path, env);
		filesystems.put(realPath, tarfs);
		return tarfs;
	}
}
 
开发者ID:PeterLaker,项目名称:archive-fs,代码行数:19,代码来源:AbstractTarFileSystemProvider.java


示例5: newFileSystem

import java.nio.file.FileSystemAlreadyExistsException; //导入依赖的package包/类
@Override
public FileSystem newFileSystem(URI uri, Map<String, ?> env) throws IOException {
  checkArgument(
      uri.getScheme().equalsIgnoreCase(URI_SCHEME),
      "uri (%s) scheme must be '%s'",
      uri,
      URI_SCHEME);
  checkArgument(
      isValidFileSystemUri(uri), "uri (%s) may not have a path, query or fragment", uri);
  checkArgument(
      env.get(FILE_SYSTEM_KEY) instanceof FileSystem,
      "env map (%s) must contain key '%s' mapped to an instance of %s",
      env, FILE_SYSTEM_KEY, FileSystem.class);

  FileSystem fileSystem = (FileSystem) env.get(FILE_SYSTEM_KEY);
  if (fileSystems.putIfAbsent(uri, fileSystem) != null) {
    throw new FileSystemAlreadyExistsException(uri.toString());
  }
  return fileSystem;
}
 
开发者ID:google,项目名称:jimfs,代码行数:21,代码来源:SystemJimfsFileSystemProvider.java


示例6: getFileSystem

import java.nio.file.FileSystemAlreadyExistsException; //导入依赖的package包/类
private static FileSystem getFileSystem(URI uri) throws IOException {
  try {
    return FileSystems.newFileSystem(uri, Collections.<String, Object> emptyMap());
  } catch (FileSystemAlreadyExistsException e) {
    return FileSystems.getFileSystem(uri);
  }
}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:8,代码来源:ResourceUtils.java


示例7: getFileSystem

import java.nio.file.FileSystemAlreadyExistsException; //导入依赖的package包/类
private FileSystem getFileSystem(URI uri) throws IOException {
  try {
    return FileSystems.newFileSystem(uri, Collections.<String, Object> emptyMap());
  } catch (FileSystemAlreadyExistsException e) { // NOSONAR
    return FileSystems.getFileSystem(uri);
  }
}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:8,代码来源:Messages.java


示例8: newFileSystem

import java.nio.file.FileSystemAlreadyExistsException; //导入依赖的package包/类
@Override
public BundleFileSystem newFileSystem(URI uri, Map<String, ?> env)
		throws IOException {

	Path localPath = localPathFor(uri);
	URI baseURI = baseURIFor(uri);

	if (asBoolean(env.get("create"), false)) {
		createBundleAsZip(localPath, (String) env.get("mimetype"));
	}

	BundleFileSystem fs;
	synchronized (openFilesystems) {
		WeakReference<BundleFileSystem> existingRef = openFilesystems
				.get(baseURI);
		if (existingRef != null) {
			BundleFileSystem existing = existingRef.get();
			if (existing != null && existing.isOpen()) {
				throw new FileSystemAlreadyExistsException(
						baseURI.toASCIIString());
			}
		}
		FileSystem origFs = FileSystems.newFileSystem(localPath, null);
		fs = new BundleFileSystem(origFs, baseURI);
		openFilesystems.put(baseURI,
				new WeakReference<BundleFileSystem>(fs));
	}
	return fs;
}
 
开发者ID:apache,项目名称:incubator-taverna-language,代码行数:30,代码来源:BundleFileSystemProvider.java


示例9: newFileSystem

import java.nio.file.FileSystemAlreadyExistsException; //导入依赖的package包/类
@Override
public FileSystem newFileSystem(URI uri, Map<String, ?> env)
        throws IOException {

    if (uri == null || env == null) {
        throw new NullPointerException();
    }
    String name = validateUriAndGetName(uri);
    EphemeralFsFileSystem answer = new EphemeralFsFileSystem(name, new Settings(env), this);
    if (fileSystems.putIfAbsent(name, answer) != null) {
        throw new FileSystemAlreadyExistsException(
                "A filesystem already exists with the name:" + name);
    }
    return answer;
}
 
开发者ID:sbridges,项目名称:ephemeralfs,代码行数:16,代码来源:EphemeralFsFileSystemProvider.java


示例10: getPathInClasspath

import java.nio.file.FileSystemAlreadyExistsException; //导入依赖的package包/类
public static Path getPathInClasspath(URL resource) throws IOException, URISyntaxException {

    Objects.requireNonNull(resource, "Resource URL cannot be null");
    URI uri = resource.toURI();

    String scheme = uri.getScheme();
    if (scheme.equals("file")) {
      return Paths.get(uri);
    }

    if (!scheme.equals("jar")) {
      throw new IllegalArgumentException("Cannot convert to Path: " + uri);
    }

    String uriStr = uri.toString();
    int separator = uriStr.indexOf("!/");
    String entryName = uriStr.substring(separator + 2);
    URI fileUri = URI.create(uriStr.substring(0, separator));

    FileSystem fs = null;

    try {

      fs = FileSystems.newFileSystem(fileUri, Collections.<String, Object>emptyMap());

    } catch (FileSystemAlreadyExistsException e) {
      fs = FileSystems.getFileSystem(fileUri);
    }

    return fs.getPath(entryName);
  }
 
开发者ID:Kurento,项目名称:kurento-module-creator,代码行数:32,代码来源:PathUtils.java


示例11: newFileSystem

import java.nio.file.FileSystemAlreadyExistsException; //导入依赖的package包/类
@Override
public final FileSystem newFileSystem(URI uri, Map<String,?> env) {

    final String defContextId = getContextIdByMap(env,defaultContextId);
    final PathTokens tokens = resolveUri(uri, defContextId);
    final String dxContextId = tokens.contextId;
    final DxFileSystem result = newFileSystem(dxContextId, tokens.name);

    if( fileSystems.putIfAbsent(dxContextId, result) != null ) {
        throw new FileSystemAlreadyExistsException();
    }

    return result;
}
 
开发者ID:nextflow-io,项目名称:jdk7-dxfs,代码行数:15,代码来源:DxFileSystemProvider.java


示例12: newFileSystem

import java.nio.file.FileSystemAlreadyExistsException; //导入依赖的package包/类
@Override
public FileSystem newFileSystem(URI uri, Map<String, ?> env) throws IOException {
    throw new FileSystemAlreadyExistsException();
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:5,代码来源:MCRFileSystemProvider.java


示例13: getRules

import java.nio.file.FileSystemAlreadyExistsException; //导入依赖的package包/类
private ArrayList<String> getRules(URI uri) throws Exception {

    System.out.println("Getting rules from " + uri.toString());
    Path rulePath = null;
    ArrayList<String> list = new ArrayList<>();
    FileSystem fileSystem = null;

    if (uri.getScheme().equals("jar")) {
      try {
        //comment out sonar as this is closed at the end of the function
        fileSystem = FileSystems.newFileSystem(uri, Collections.<String, Object> emptyMap()); //NOSONAR
      } catch (FileSystemAlreadyExistsException e) {
        fileSystem = FileSystems.getFileSystem(uri);
      }
      rulePath = fileSystem.getPath(RULES_DIR_JAR);
    }
    else if(uri.isAbsolute()){
      rulePath = Paths.get(uri);
    }
    else {
      uri = Rules.class.getClassLoader().getResource(RULES_DIR_IDE).toURI();
      rulePath = Paths.get(uri);
    }
    Stream<Path> walk = Files.walk(rulePath, 1);
    for (Iterator<Path> it = walk.iterator(); it.hasNext();) {
      Path file = it.next();
      String name = file.getFileName().toString();
      if(name.endsWith("drl")){
        if (uri.getScheme().equals("jar")) {
          list.add(name);
        }else{
          list.add(file.toAbsolutePath().toString());
        }
      }
    }
    walk.close();
    if (fileSystem != null) {
      fileSystem.close();
    }
    return list;
  }
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:42,代码来源:Rules.java


示例14: newFileSystem

import java.nio.file.FileSystemAlreadyExistsException; //导入依赖的package包/类
@Override
public FileSystem newFileSystem(URI uri, Map<String, ?> env)
		throws IOException {
	assertUri(uri);
	synchronized (EncryptedFileSystemProvider.class) {
		if (encFileSystem != null)
			throw new FileSystemAlreadyExistsException();

		// check environment
		try {
			String cipherAlgorithm = (String) env.get(CIPHER_ALGORITHM);
			if (cipherAlgorithm == null)
				throw new IllegalArgumentException(
						"Missing filesystem variable '" + CIPHER_ALGORITHM
								+ "'");

			String cipherAlgorithmMode = (String) env
					.get(CIPHER_ALGORITHM_MODE);
			if (cipherAlgorithmMode == null)
				throw new IllegalArgumentException(
						"Missing filesystem variable '"
								+ CIPHER_ALGORITHM_MODE + "'");

			String cipherAlgorithmPadding = (String) env
					.get(CIPHER_ALGORITHM_PADDING);
			if (cipherAlgorithmPadding == null)
				throw new IllegalArgumentException(
						"Missing filesystem variable '"
								+ CIPHER_ALGORITHM_PADDING + "'");

			cipherTransformation = cipherAlgorithm + "/"
					+ cipherAlgorithmMode + "/" + cipherAlgorithmPadding;
			Cipher.getInstance(cipherTransformation);
			// FSTODO: cipher.getParameters().getProvider() --> check secret
			// key length ?

			byte[] secretKey = (byte[]) env.get(SECRET_KEY);
			if (secretKey == null)
				throw new IllegalArgumentException(
						"Missing filesystem variable '" + SECRET_KEY + "'");

			secretKeySpec = new SecretKeySpec(secretKey, cipherAlgorithm);

			String fileSystemRootString = (String) env
					.get(FILESYSTEM_ROOT_URI);
			if (fileSystemRootString == null)
				fileSystemRootString = "file:/";
			fileSystemRoot = Paths.get(new URI(fileSystemRootString))
					.normalize();

			String isReverseString = (String) env.get(REVERSE_MODE);
			isReverse = "true".equalsIgnoreCase(isReverseString);

		} catch (Exception e) {
			throw new IOException(e);
		}

		EncryptedFileSystem result = new EncryptedFileSystem(this,
				FileSystems.getDefault());
		encFileSystem = result;
		return result;
	}
}
 
开发者ID:usrflo,项目名称:encfs4j,代码行数:64,代码来源:EncryptedFileSystemProvider.java


示例15: testCreateTwiceSameURIFails

import java.nio.file.FileSystemAlreadyExistsException; //导入依赖的package包/类
@Test(expected=FileSystemAlreadyExistsException.class)
public void testCreateTwiceSameURIFails() throws Exception { 
    createTestFs();
    createTestFs();
}
 
开发者ID:sbridges,项目名称:ephemeralfs,代码行数:6,代码来源:EphemeralFsProviderTest.java


示例16: newFileSystem

import java.nio.file.FileSystemAlreadyExistsException; //导入依赖的package包/类
public FileSystem newFileSystem( EightyProvider eightyProvider, URI uri, Map<String, ?> env2 ) {

        checkURI( uri );

        Map<String, Object> env = (Map) env2;

        String id = uriMapper.getSchemeSpecificPart( uri );

        if( fileSystems.containsKey( id ) && fileSystems.get( id ).isOpen() ) {
            throw new FileSystemAlreadyExistsException( id );
        }

        Object fsid = uriMapper.fromString( id, env );

        RWAttributesBuilder attributesBuilder = RWAttributesBuilder.attributes();
        EightyFS efs = creator.create( fsid, attributesBuilder, env );

        EightyFileSystem eightyFileSystem = new EightyFileSystem( efs, id, eightyProvider, attributesBuilder.build() );
        fileSystems.put( id, eightyFileSystem );

        efs.setWatcher( eightyFileSystem );

        return eightyFileSystem;
    }
 
开发者ID:openCage,项目名称:eightyfs,代码行数:25,代码来源:ProviderURIStuff.java


示例17: testNewFileSystemOfExistingThrows

import java.nio.file.FileSystemAlreadyExistsException; //导入依赖的package包/类
@Test
public void testNewFileSystemOfExistingThrows() throws IOException {
    assertThatThrownBy( () -> FS.provider().newFileSystem( toURI( FS ), getEnv() ) ).
            isInstanceOf( FileSystemAlreadyExistsException.class );
}
 
开发者ID:openCage,项目名称:niotest,代码行数:6,代码来源:Tests05URI.java



注:本文中的java.nio.file.FileSystemAlreadyExistsException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PluginEntryPoint类代码示例发布时间:2022-05-21
下一篇:
Java LatLng类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap