in src/main/java/org/apache/commons/io/IOUtils.java [972:1015]
public static boolean contentEquals(final Reader input1, final Reader input2) throws IOException {
if (input1 == input2) {
return true;
}
if (input1 == null || input2 == null) {
return false;
}
// reuse one
final char[] array1 = getScratchCharArray();
// but allocate another
final char[] array2 = charArray();
int pos1;
int pos2;
int count1;
int count2;
while (true) {
pos1 = 0;
pos2 = 0;
for (int index = 0; index < DEFAULT_BUFFER_SIZE; index++) {
if (pos1 == index) {
do {
count1 = input1.read(array1, pos1, DEFAULT_BUFFER_SIZE - pos1);
} while (count1 == 0);
if (count1 == EOF) {
return pos2 == index && input2.read() == EOF;
}
pos1 += count1;
}
if (pos2 == index) {
do {
count2 = input2.read(array2, pos2, DEFAULT_BUFFER_SIZE - pos2);
} while (count2 == 0);
if (count2 == EOF) {
return pos1 == index && input1.read() == EOF;
}
pos2 += count2;
}
if (array1[index] != array2[index]) {
return false;
}
}
}
}