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

Method equal

corpus/java/training/guava/io/Files.java:367–385  ·  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

365 * @throws IOException if an I/O error occurs
366 */
367 public static boolean equal(File file1, File file2) throws IOException {
368 checkNotNull(file1);
369 checkNotNull(file2);
370 if (file1 == file2 || file1.equals(file2)) {
371 return true;
372 }
373
374 /*
375 * Some operating systems may return zero as the length for files denoting system-dependent
376 * entities such as devices or pipes, in which case we must fall back on comparing the bytes
377 * directly.
378 */
379 long len1 = file1.length();
380 long len2 = file2.length();
381 if (len1 != 0 && len2 != 0 && len1 != len2) {
382 return false;
383 }
384 return asByteSource(file1).contentEquals(asByteSource(file2));
385 }
386
387 /**
388 * 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