Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.FileInputStream; import java.util.Arrays; public class Main { @SuppressWarnings("resource") public static boolean isSameContent(String srcFilename, String destFilename) { try { FileInputStream src = new FileInputStream(srcFilename); FileInputStream dst = new FileInputStream(destFilename); byte[] bsrc = new byte[1024]; byte[] bdst = new byte[1024]; int n; while ((n = src.read(bsrc)) != -1) { int m = dst.read(bdst); if (m == -1) return false; if (m != n) return false; if (!Arrays.equals(bsrc, bdst)) return false; } return true; } catch (Exception e) { return false; } } }