/** Like {@link #match(List)}, but with a configurable {@link EmptyMatchTreatment}. */ public static List<MatchResult> match(List<String> specs, EmptyMatchTreatment emptyMatchTreatment) throws IOException { List<MatchResult> matches = getFileSystemInternal(getOnlyScheme(specs)).match(specs); List<MatchResult> res = Lists.newArrayListWithExpectedSize(matches.size()); for (int i = 0; i < matches.size(); i++) { res.add(maybeAdjustEmptyMatchResult(specs.get(i), matches.get(i), emptyMatchTreatment)); } return res; }
/** * Returns a read channel for the given {@link ResourceId}. * * <p>The resource is not expanded; it is used verbatim. * * <p>If seeking is supported, then this returns a {@link java.nio.channels.SeekableByteChannel}. * * @param resourceId the reference of the file-like resource to open */ public static ReadableByteChannel open(ResourceId resourceId) throws IOException { return getFileSystemInternal(resourceId.getScheme()).open(resourceId); }
/** * Returns a write channel for the given {@link ResourceId} with {@link CreateOptions}. * * <p>The resource is not expanded; it is used verbatim. * * @param resourceId the reference of the file-like resource to create * @param createOptions the configuration of the create operation */ public static WritableByteChannel create(ResourceId resourceId, CreateOptions createOptions) throws IOException { return getFileSystemInternal(resourceId.getScheme()).create(resourceId, createOptions); }
/** * Returns a new {@link ResourceId} that represents the named resource of a type corresponding to * the resource type. * * <p>The supplied {@code singleResourceSpec} is expected to be in a proper format, including any * necessary escaping, for the underlying {@link FileSystem}. * * <p>This function may throw an {@link IllegalArgumentException} if given an invalid argument, * such as when the specified {@code singleResourceSpec} is not a valid resource name. */ public static ResourceId matchNewResource(String singleResourceSpec, boolean isDirectory) { return getFileSystemInternal(parseScheme(singleResourceSpec)) .matchNewResource(singleResourceSpec, isDirectory); } }
return getFileSystemInternal(getOnlyScheme(specs)).match(specs);
return; getFileSystemInternal(srcToCopy.iterator().next().getScheme()).copy(srcToCopy, destToCopy);
return; getFileSystemInternal(srcToRename.iterator().next().getScheme()) .rename(srcToRename, destToRename);
return; getFileSystemInternal(resourceIdsToDelete.iterator().next().getScheme()) .delete(resourceIdsToDelete);
@Test public void testGetLocalFileSystem() throws Exception { assertTrue( FileSystems.getFileSystemInternal(toLocalResourceId("~/home/").getScheme()) instanceof LocalFileSystem); assertTrue( FileSystems.getFileSystemInternal(toLocalResourceId("file://home").getScheme()) instanceof LocalFileSystem); assertTrue( FileSystems.getFileSystemInternal(toLocalResourceId("FILE://home").getScheme()) instanceof LocalFileSystem); assertTrue( FileSystems.getFileSystemInternal(toLocalResourceId("File://home").getScheme()) instanceof LocalFileSystem); if (SystemUtils.IS_OS_WINDOWS) { assertTrue( FileSystems.getFileSystemInternal(toLocalResourceId("c:\\home\\").getScheme()) instanceof LocalFileSystem); } }