public static String readString(File file, Charset charset) throws IOException {
        if (file == null || !file.isFile()) {
            return null;
        }
        StringBuilder fileContent = new StringBuilder();

        BufferedReader reader = null;
        try {
            InputStreamReader is = new InputStreamReader(new FileInputStream(file), charset);
            reader = new BufferedReader(is);
            String line = null;
            while ((line = reader.readLine()) != null) {
                if (!fileContent.toString().equals("")) {
                    fileContent.append("\r\n");
                }
                fileContent.append(line);
            }
            reader.close();
            return fileContent.toString();
        } finally {
            closeQuietly(reader);
        }
    }
public static String readString ( File file , Charset charset ) throws IOException { if ( file == null || ! file . isFile ( ) ) { return null ; } StringBuilder fileContent = new StringBuilder ( ) ; BufferedReader reader = null ; try { InputStreamReader is = new InputStreamReader ( new FileInputStream ( file ) , charset ) ; reader = new BufferedReader ( is ) ; String line = null ; while ( ( line = reader . readLine ( ) ) != null ) { if ( ! fileContent . toString ( ) . equals ( "" ) ) { fileContent . append ( "\r\n" ) ; } fileContent . append ( line ) ; } reader . close ( ) ; return fileContent . toString ( ) ; } finally { closeQuietly ( reader ) ; } }
read file

@param file    file
@param charset The name of a supported {@link Charset </code>charset<code>}
@return if file not exist, return null, else return content of file
@throws IOException if an error occurs while operator BufferedReader