FileSystems { public static void copy( List<ResourceId> srcResourceIds, List<ResourceId> destResourceIds, MoveOptions... moveOptions) throws IOException { validateSrcDestLists(srcResourceIds, destResourceIds); if (srcResourceIds.isEmpty()) { return; } List<ResourceId> srcToCopy = srcResourceIds; List<ResourceId> destToCopy = destResourceIds; if (Sets.newHashSet(moveOptions) .contains(MoveOptions.StandardMoveOptions.IGNORE_MISSING_FILES)) { KV<List<ResourceId>, List<ResourceId>> existings = filterMissingFiles(srcResourceIds, destResourceIds); srcToCopy = existings.getKey(); destToCopy = existings.getValue(); } if (srcToCopy.isEmpty()) { return; } getFileSystemInternal(srcToCopy.iterator().next().getScheme()).copy(srcToCopy, destToCopy); }  static boolean hasGlobWildcard(String spec); static List<MatchResult> match(List<String> specs); static List<MatchResult> match(List<String> specs, EmptyMatchTreatment emptyMatchTreatment); static MatchResult match(String spec); static MatchResult match(String spec, EmptyMatchTreatment emptyMatchTreatment); static Metadata matchSingleFileSpec(String spec); static List<MatchResult> matchResources(List<ResourceId> resourceIds); static WritableByteChannel create(ResourceId resourceId, String mimeType); static WritableByteChannel create(ResourceId resourceId, CreateOptions createOptions); static ReadableByteChannel open(ResourceId resourceId); static void copy(
      List<ResourceId> srcResourceIds, List<ResourceId> destResourceIds, MoveOptions... moveOptions); static void rename(
      List<ResourceId> srcResourceIds, List<ResourceId> destResourceIds, MoveOptions... moveOptions); static void delete(Collection<ResourceId> resourceIds, MoveOptions... moveOptions); @Internal static void setDefaultPipelineOptions(PipelineOptions options); static ResourceId matchNewResource(String singleResourceSpec, boolean isDirectory); static final String DEFAULT_SCHEME; }
@Test public void testCopyThrowsNoSuchFileException() throws Exception { Path existingPath = temporaryFolder.newFile().toPath(); Path nonExistentPath = existingPath.resolveSibling("non-existent"); Path destPath1 = existingPath.resolveSibling("dest1"); Path destPath2 = nonExistentPath.resolveSibling("dest2"); createFileWithContent(existingPath, "content1"); thrown.expect(NoSuchFileException.class); FileSystems.copy( toResourceIds(ImmutableList.of(existingPath, nonExistentPath), false ), toResourceIds(ImmutableList.of(destPath1, destPath2), false )); }
@Test public void testCopyIgnoreMissingFiles() throws Exception { Path srcPath1 = temporaryFolder.newFile().toPath(); Path nonExistentPath = srcPath1.resolveSibling("non-existent"); Path srcPath3 = temporaryFolder.newFile().toPath(); Path destPath1 = srcPath1.resolveSibling("dest1"); Path destPath2 = nonExistentPath.resolveSibling("dest2"); Path destPath3 = srcPath1.resolveSibling("dest3"); createFileWithContent(srcPath1, "content1"); createFileWithContent(srcPath3, "content3"); FileSystems.copy( toResourceIds( ImmutableList.of(srcPath1, nonExistentPath, srcPath3), false ), toResourceIds(ImmutableList.of(destPath1, destPath2, destPath3), false ), MoveOptions.StandardMoveOptions.IGNORE_MISSING_FILES); assertTrue(srcPath1.toFile().exists()); assertTrue(srcPath3.toFile().exists()); assertThat( Files.readLines(srcPath1.toFile(), StandardCharsets.UTF_8), containsInAnyOrder("content1")); assertFalse(destPath2.toFile().exists()); assertThat( Files.readLines(srcPath3.toFile(), StandardCharsets.UTF_8), containsInAnyOrder("content3")); }