Compares the contents of the two {@link InputStream}s for equality.
(InputStream in1, InputStream in2)
| 953 | |
| 954 | /** Compares the contents of the two {@link InputStream}s for equality. */ |
| 955 | static boolean contentsEqual(InputStream in1, InputStream in2) throws IOException { |
| 956 | byte[] buf1 = createBuffer(); |
| 957 | byte[] buf2 = createBuffer(); |
| 958 | while (true) { |
| 959 | int read1 = read(in1, buf1, 0, BUFFER_SIZE); |
| 960 | int read2 = read(in2, buf2, 0, BUFFER_SIZE); |
| 961 | if (read1 != read2 || !arraysEqual(buf1, buf2, read1)) { |
| 962 | return false; |
| 963 | } else if (read1 != BUFFER_SIZE) { |
| 964 | return true; |
| 965 | } |
| 966 | } |
| 967 | } |
| 968 | |
| 969 | // The Arrays.equals(<arraytype>, int, int, <arraytype>, int, int) methods were not added until |
| 970 | // Java 9. This function is just returns the same result that |
no test coverage detected