MCPcopy
hub / github.com/google/guava / equal

Method equal

android/guava/src/com/google/common/io/Files.java:371–389  ·  view source on GitHub ↗

Returns true if the given files exist, are not directories, and contain the same bytes. @throws IOException if an I/O error occurs

(File file1, File file2)

Source from the content-addressed store, hash-verified

369 * @throws IOException if an I/O error occurs
370 */
371 public static boolean equal(File file1, File file2) throws IOException {
372 checkNotNull(file1);
373 checkNotNull(file2);
374 if (file1 == file2 || file1.equals(file2)) {
375 return true;
376 }
377
378 /*
379 * Some operating systems may return zero as the length for files denoting system-dependent
380 * entities such as devices or pipes, in which case we must fall back on comparing the bytes
381 * directly.
382 */
383 long len1 = file1.length();
384 long len2 = file2.length();
385 if (len1 != 0 && len2 != 0 && len1 != len2) {
386 return false;
387 }
388 return asByteSource(file1).contentEquals(asByteSource(file2));
389 }
390
391 /**
392 * Atomically creates a new directory somewhere beneath the system's temporary directory (as

Callers 4

testEqualMethod · 0.95
testNewWriterMethod · 0.95
testMoveMethod · 0.95
testMoveViaCopyMethod · 0.95

Calls 5

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

Tested by 4

testEqualMethod · 0.76
testNewWriterMethod · 0.76
testMoveMethod · 0.76
testMoveViaCopyMethod · 0.76