Fast way to compare inputstreams
问题 I have a problem, I need to compare two inputstreams fast. Today I have a function like this: private boolean isEqual(InputStream i1, InputStream i2) throws IOException { try { // do the compare while (true) { int fr = i1.read(); int tr = i2.read(); if (fr != tr) return false; if (fr == -1) return true; } } finally { if (i1 != null) i1.close(); if (i2 != null) i2.close(); } } But it's really slow. I want to use buffered reads but have not come up with a good way of doing it. Some extra stuff