ResourceUtil { public static void copyResource(WEB_RESOURCE source, String destPath) throws IOException { File sourceFile = new File(ResourceUtil.class.getResource("/web/" + source.toString()).getPath()); File destFile = new File(destPath); File tmpFile = new File(destFile.getAbsoluteFile() + File.separator + sourceFile.getName()); FileUtils.copyFile(sourceFile, tmpFile); }  static void copyResource(WEB_RESOURCE source, String destPath);  }
@Test public void testResourceCopy() throws IOException, InstantiationException, IllegalAccessException { File target = new File("tmpDir"); WEB_RESOURCE resource = WEB_RESOURCE.JQUERY; ResourceUtil.copyResource(resource, target.getAbsolutePath()); assertTrue(target.listFiles()[0].getName().contains(resource.toString())); FileUtils.deleteDirectory(target); }