public static String getFileAsString(File file) throws FileNotFoundException, IOException  {
        byte[] inputbytes;
        try (RandomAccessFile inputFile = new RandomAccessFile(file, "r")) {
            int length = (int) inputFile.length();
            inputbytes = new byte[length];
            int numread = inputFile.read(inputbytes);
        }
        return new String(inputbytes);
    }
public static String getFileAsString ( File file ) throws FileNotFoundException , IOException { byte [ ] inputbytes ; try ( RandomAccessFile inputFile = new RandomAccessFile ( file , "r" ) ) { int length = ( int ) inputFile . length ( ) ; inputbytes = new byte [ length ] ; int numread = inputFile . read ( inputbytes ) ; } return new String ( inputbytes ) ; }
Returns the <code>String</code> contents of an ASCII file.
<p>
This method throws any fileIO errors.

@param file File to read.
@return String The contents of the file as a String.
@throws java.io.FileNotFoundException If the input file cannot be found
@throws java.io.IOException If other I/O errors occur