Returns true if the files contains the same bytes. @throws IOException if an I/O error occurs
(File file1, File file2)
| 389 | |
| 390 | |
| 391 | public static boolean equal(File file1, File file2) throws IOException { |
| 392 | checkNotNull(file1); |
| 393 | checkNotNull(file2); |
| 394 | if (file1 == file2 || file1.equals(file2)) { |
| 395 | return true; |
| 396 | } |
| 397 | |
| 398 | /* |
| 399 | * Some operating systems may return zero as the length for files denoting system-dependent |
| 400 | * entities such as devices or pipes, in which case we must fall back on comparing the bytes |
| 401 | * directly. |
| 402 | */ |
| 403 | long len1 = file1.length(); |
| 404 | long len2 = file2.length(); |
| 405 | if (len1 != 0 && len2 != 0 && len1 != len2) { |
| 406 | return false; |
| 407 | } |
| 408 | return asByteSource(file1).contentEquals(asByteSource(file2)); |
| 409 | } |
| 410 | |
| 411 | /** |
| 412 | * Atomically creates a new directory somewhere beneath the system's temporary directory (as |
nothing calls this directly
no test coverage detected