if (is == null) {
throw new IOException("Unable to read file " +
"/"+Common.DATA_FOLDER+"/" + Common.LANGUAGE_FILE);
}
EncodingUtil encUtl = new EncodingUtil(is);
EncodingStreamReader esr = encUtl.getEncodingStreamReader();
StringBuffer inputBuffer;
try {
inputBuffer = esr.readFile(Common.LANGUAGE_FILE_LEN);
} catch (IOException ex) {
CauseException cex = new CauseException(
"Error while reading file.", ex);
throw cex;
} finally {
if (is != null) {
try {
is.close();
} catch (Exception e) {
}
}
}
String text;
/* If not UTF-8, treat it as one since we use XSL to create UTF-8.
I couldn't create a file with BOM, so this is the next best
thing. */
final String fileEncoding = esr.getFileEncoding();
if (!esr.isUtfDoc()) {
esr.setUtfDoc(true);
encUtl.getEncoding(fileEncoding, "UTF-8");
}
if (esr.isUtfDoc()) {
if (esr.isUtf16Doc()) {
encUtl.getEncoding(fileEncoding, "UTF-16");
} else {
encUtl.getEncoding(fileEncoding, "UTF-8");
}
final String docEncoding = encUtl.getDocEncoding();