public static String readFileToString ( File file ) throws IOException { Assert . isTrue ( file . exists ( ) , "File '" + file + "' does not exist" ) ; Assert . isFalse ( file . isDirectory ( ) , "File '" + file + "' is a directory" ) ; Assert . isTrue ( file . canRead ( ) , "File '" + file + "' cannot be read" ) ; FileInputStream stream = new FileInputStream ( file ) ; return getString ( stream ) ; }
Reads file into String