public LessSource(File input) throws IOException {
this( new FileResource(input) );
}
private String loadResource(Resource resource, Charset charset) throws IOException {
BOMInputStream inputStream = new BOMInputStream( resource.getInputStream() );
try {
if( inputStream.hasBOM() ) {
logger.debug("BOM found %s", inputStream.getBOMCharsetName());
return IOUtils.toString(inputStream, inputStream.getBOMCharsetName());
} else {
logger.debug("Using charset " + charset.name());
return IOUtils.toString(inputStream, charset.name());
}
}
finally {
inputStream.close();
}
}