### Question:
ResourceUtil { public static boolean existsResource(String resourceName) { InputStream is = null; try { try { is = new BufferedInputStream(FileUtil.class.getResource(resourceName).openStream()); } catch (Throwable e) { is = new BufferedInputStream( Thread.currentThread().getContextClassLoader().getResource(resourceName).openStream()); } return is != null; } catch (Throwable e) { return false; } finally { if (is != null) try { is.close(); } catch (IOException e) { } } }  static String readAsString(String resourceName); static void copyResource(String classpath, File out); static boolean existsResource(String resourceName);  }### Answer:
@Test public void testExistsResource() throws IOException { Assert.assertTrue(ResourceUtil.existsResource("/context.xml")); Assert.assertFalse(ResourceUtil.existsResource("/test.txt")); }