public static File getFileFromClasspath ( final String filePath ) throws FileNotFoundException { try { URL fileURL = FileUtils . class . getClassLoader ( ) . getResource ( filePath ) ; if ( fileURL == null ) { throw new FileNotFoundException ( "File [" + filePath + "] could not be found in classpath" ) ; } return new File ( fileURL . toURI ( ) ) ; } catch ( URISyntaxException e ) { throw new FileNotFoundException ( "File [" + filePath + "] could not be found: " + e . getMessage ( ) ) ; } }
Searches the classpath for the file denoted by the file path and returns the corresponding file .