+
+ public static String readContentsWithCharset(String charset, String fileName) throws IOException {
+ try {
+ Charset cs = Charset.forName(charset);
+ return new String(Files.readAllBytes(Paths.get(fileName)), cs);
+ } catch(MalformedInputException e) {
+ throw new RuntimeException("Encoding of the file '" + fileName + "' does not conform to " + charset + ".");
+ }
+ }
+