FileUtils { public static InputStream lookupFile(final String filename) throws IOException { Preconditions.checkNotNull(filename, "filename"); final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); InputStream stream = classLoader.getResourceAsStream(filename); if (stream == null) { if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format( "Unable to find file {0} in classpath. Searching for this file on the filesystem instead.", filename)); } stream = new FileInputStream(filename); } return stream; } private  FileUtils(); static InputStream lookupFile(final String filename); static void writeLines(final File file, final Collection<?> collisions, final Charset charset); static List<String> readLines(final String fileName, final int numberOfLines, final Charset charset);  }
@Test(expectedExceptions = { FileNotFoundException.class }) public void testFileNotFound() throws Exception { InputStream input = null; try { input = FileUtils.lookupFile(NO_FILE); } finally { if (input != null) { try { input.close(); } catch (final IOException e) {} } } }