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) thr
Using buffered reads is just a matter of wrapping the InputStreams with BufferedInputStreams. However you are likely to get the best performance reading large blocks at a time.
private boolean isEqual(InputStream i1, InputStream i2) throws IOException {
byte[] buf1 = new byte[64 *1024];
byte[] buf2 = new byte[64 *1024];
try {
DataInputStream d2 = new DataInputStream(i2);
int len;
while ((len = i1.read(buf1)) > 0) {
d2.readFully(buf2,0,len);
for(int i=0;i