MCPcopy
hub / github.com/google/guava / move

Method move

android/guava/src/com/google/common/io/Files.java:491–505  ·  view source on GitHub ↗

Moves a file from one path to another. This method can rename a file and/or move it to a different directory. In either case {@code to} must be the target path for the file itself; not just the new name for the file or the path to the new parent directory. <p><b>{@link java.nio.file.Path} equivalen

(File from, File to)

Source from the content-addressed store, hash-verified

489 * @throws IllegalArgumentException if {@code from.equals(to)}
490 */
491 public static void move(File from, File to) throws IOException {
492 checkNotNull(from);
493 checkNotNull(to);
494 checkArgument(!from.equals(to), "Source %s and destination %s must be different", from, to);
495
496 if (!from.renameTo(to)) {
497 copy(from, to);
498 if (!from.delete()) {
499 if (!to.delete()) {
500 throw new IOException("Unable to delete " + to);
501 }
502 throw new IOException("Unable to delete " + from);
503 }
504 }
505 }
506
507 /**
508 * Reads the first line from a file. The line does not include line-termination characters, but

Callers 1

moveHelperMethod · 0.95

Calls 6

copyMethod · 0.95
equalsMethod · 0.65
checkNotNullMethod · 0.45
checkArgumentMethod · 0.45
renameToMethod · 0.45
deleteMethod · 0.45

Tested by 1

moveHelperMethod · 0.76