MCPcopy Create free account
hub / github.com/antlr/codebuff / move

Method move

corpus/java/training/guava/io/Files.java:475–489  ·  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 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. @param from the source file @param to the

(File from, File to)

Source from the content-addressed store, hash-verified

473 * @throws IllegalArgumentException if {@code from.equals(to)}
474 */
475 public static void move(File from, File to) throws IOException {
476 checkNotNull(from);
477 checkNotNull(to);
478 checkArgument(!from.equals(to), "Source %s and destination %s must be different", from, to);
479
480 if (!from.renameTo(to)) {
481 copy(from, to);
482 if (!from.delete()) {
483 if (!to.delete()) {
484 throw new IOException("Unable to delete " + to);
485 }
486 throw new IOException("Unable to delete " + from);
487 }
488 }
489 }
490
491 /**
492 * Reads the first line from a file. The line does not include line-termination characters, but

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected