public static String readFileAsString(File file,String encoding) throws IOException {
  ByteBuffer buffer=readFile(file);
  if (null == encoding) {
    encoding="UTF-8";
  }
  String converted=new String(buffer.array(),encoding);
  return converted;
}

public static String readFileAsString ( File file , String encoding ) throws IOException { ByteBuffer buffer = readFile ( file ) ; if ( null == encoding ) { encoding = "UTF-8" ; } String converted = new String ( buffer . array ( ) , encoding ) ; return converted ; }
new nio based method to read a file as a string with the given encoding .
