commons-file/src/main/java/info/monitorenter/util/FileUtil.java
public static boolean isEqual(final File document, final Charset a, final Charset b)
      throws IOException {
    boolean ret = true;
    FileInputStream aIn = null;
    FileInputStream bIn = null;
    InputStreamReader aReader = null;
    InputStreamReader bReader = null;
    try {
      aIn = new FileInputStream(document);
      bIn = new FileInputStream(document);
      aReader = new InputStreamReader(aIn, a);
      bReader = new InputStreamReader(bIn, b);
      int readA = -1;
      int readB = -1;
      do {
        readA = aReader.read();
        readB = bReader.read();
        if (readA != readB) {
          // also the case, if one is at the end earlier...
          ret = false;
          break;
        }
      } while ((readA != -1) && (readB != -1));
      return ret;
    } finally {
      if (aReader != null) {
        aReader.close();
      }
      if (bReader != null) {
        bReader.close();
      }
    }
  }
public static boolean isEqual(final File document, final Charset a, final Charset b)
      throws IOException {
    boolean ret = true;
    FileInputStream aIn = null;
    FileInputStream bIn = null;
    InputStreamReader aReader = null;
    InputStreamReader bReader = null;
    try {
      aIn = new FileInputStream(document);
      bIn = new FileInputStream(document);
      aReader = new InputStreamReader(aIn, a);
      bReader = new InputStreamReader(bIn, b);
      int readA = -1;
      int readB = -1;
      do {
        readA = aReader.read();
        readB = bReader.read();
        if (readA != readB) {
          // also the case, if one is at the end earlier...
          ret = false;
          break;
        }
      } while ((readA != -1) && (readB != -1));
      return ret;
    } finally {
      if (aReader != null) {
        aReader.close();
      }
      if (bReader != null) {
        bReader.close();
      }
    }
  }
Tests, wether the content of the given file is identical at character
level, when it is opened with both different Charsets.
<p>
This is most often the case, if the given file only contains ASCII codes
but may also occur, when both codepages cover common ranges and the
document only contains values m_out of those ranges (like the EUC-CN
charset contains all mappings from BIG5).
<p>

@param document
the file to test.

@param a
the first character set to interpret the document in.

@param b
the 2nd character set to interpret the document in.

@throws java.io.IOException
if something goes wrong.

@return true if both files have all equal contents if they are interpreted
as character data in both given encodings (they may differ at
binary level if both charsets are different).