public static String readFileToString(String fileName,String charset) throws IOException {
  Reader input=new InputStreamReader(new FileInputStream(fileName),charset);
  StringWriter output=new StringWriter();
  char[] buf=new char[4096];
  int n;
  while ((n=input.read(buf)) != -1)   output.write(buf,0,n);
  return output.toString();
}

public static String readFileToString ( String fileName , String charset ) throws IOException { Reader input = new InputStreamReader ( new FileInputStream ( fileName ) , charset ) ; StringWriter output = new StringWriter ( ) ; char [ ] buf = new char [ 4096 ] ; int n ; while ( ( n = input . read ( buf ) ) != - 1 ) output . write ( buf , 0 , n ) ; return output . toString ( ) ; }
reads file to string using specified charset .
