public static String loadFile ( String filename ) { ClassLoader classLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; InputStream is = classLoader . getResourceAsStream ( filename ) ; if ( is == null ) { throw new IllegalArgumentException ( "Unable to locate: " + filename ) ; } return streamToString ( is , filename ) ; }
Reads content of UTF - 8 file on classpath to String .