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)
| 502 | |
| 503 | |
| 504 | public static void move(File from, File to) throws IOException { |
| 505 | checkNotNull(from); |
| 506 | checkNotNull(to); |
| 507 | checkArgument(!from.equals(to), "Source %s and destination %s must be different", from, to); |
| 508 | if (!from.renameTo(to)) { |
| 509 | copy(from, to); |
| 510 | if (!from.delete()) { |
| 511 | if (!to.delete()) { |
| 512 | throw new IOException("Unable to delete " + to); |
| 513 | } |
| 514 | throw new IOException("Unable to delete " + from); |
| 515 | } |
| 516 | } |
| 517 | } |
| 518 | |
| 519 | /** |
| 520 | * Reads the first line from a file. The line does not include line-termination characters, but |
nothing calls this directly
no test coverage detected