Java tutorial
//package com.java2s; import java.io.IOException; import java.io.InputStream; public class Main { private static final int DEFAULT_BUFFER_SIZE = 1024 * 4; public static boolean equals(InputStream ins1, InputStream ins2) throws IOException { byte[] buf1 = new byte[DEFAULT_BUFFER_SIZE]; byte[] buf2 = new byte[DEFAULT_BUFFER_SIZE]; do { int len1 = ins1.read(buf1); int len2 = ins2.read(buf2); if (len1 != len2) return false; if (len1 == -1) return true; for (int i = 0; i < len1; i++) { if (buf1[i] != buf2[i]) return false; } } while (true); } }