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

Method equal

output/java_guava/1.4.19/Files.java:391–409  ·  view source on GitHub ↗

Returns true if the files contains the same bytes. @throws IOException if an I/O error occurs

(File file1, File file2)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

asByteSourceMethod · 0.95
equalsMethod · 0.65
checkNotNullMethod · 0.45
lengthMethod · 0.45
contentEqualsMethod · 0.45

Tested by

no test coverage detected