use of org.apache.commons.io.input.BOMInputStream in project CFLint by cflint.
the class FileUtil method loadFile.
public static String loadFile(final File file) {
FileInputStream fis = null;
try {
fis = new FileInputStream(file);
try {
final BOMInputStream bOMInputStream = new BOMInputStream(fis);
final ByteOrderMark bom = bOMInputStream.getBOM();
final String charsetName = bom == null ? DEFAULT_ENCODING : bom.getCharsetName();
InputStreamReader reader = new InputStreamReader(new BufferedInputStream(bOMInputStream), charsetName);
return readFully(reader);
} finally {
fis.close();
}
} catch (final Exception e) {
return null;
} finally {
try {
if (fis != null) {
fis.close();
}
} catch (final IOException e) {
}
}
}
Aggregations