public static String read(File file, String charset) throws IOException {
        InputStream inputStream = null;

        try {
            inputStream = new FileInputStream(file);

            int length = (int)(file.length());
            byte[] buffer = new byte[length];
            inputStream.read(buffer, 0, length);

            if(charset != null) {
                return new String(buffer, 0, buffer.length, charset);
            }
            else {
                return new String(buffer, 0, buffer.length);
            }
        }
        finally {
            close(inputStream);
        }
    }
public static String read ( File file , String charset ) throws IOException { InputStream inputStream = null ; try { inputStream = new FileInputStream ( file ) ; int length = ( int ) ( file . length ( ) ) ; byte [ ] buffer = new byte [ length ] ; inputStream . read ( buffer , 0 , length ) ; if ( charset != null ) { return new String ( buffer , 0 , buffer . length , charset ) ; } else { return new String ( buffer , 0 , buffer . length ) ; } } finally { close ( inputStream ) ; } }
@param file
@param charset
@return String
@throws IOException