public static BufferedReader resource ( String resourcePath ) throws IOException { InputStream is = IOUtils . class . getClassLoader ( ) . getResourceAsStream ( resourcePath ) ; if ( is != null ) { return new BufferedReader ( new InputStreamReader ( is , UTF_8 ) ) ; } else { File file = new File ( resourcePath ) ; if ( file . exists ( ) ) { return fileReader ( file ) ; } else { throw new IllegalArgumentException ( "resource does not exist " + resourcePath ) ; } } }
Read a resource from the classpath or fallback to treating it as a file .