ResourceUtils { public static File getClasspathAsFolder(String aClasspathBase, boolean aCache) throws IOException { synchronized (classpathFolderCache) { File folder = classpathFolderCache.get(aClasspathBase); ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); if (!aCache || (folder == null) || !folder.exists()) { folder = File.createTempFile("dkpro-package", ""); folder.delete(); FileUtils.forceMkdir(folder); Resource[] roots = resolver.getResources(aClasspathBase); for (Resource root : roots) { String base = root.getURL().toString(); Resource[] resources = resolver.getResources(base + "*"); for (Resource resource : resources) { if (!resource.isReadable()) { continue; } String res = resource.getURL().toString(); if (!res.startsWith(base)) { throw new IOException( "Resource location does not start with base location"); } String relative = resource.getURL().toString().substring(base.length()); File target = new File(folder, relative).getAbsoluteFile(); if (target.getParentFile() != null) { FileUtils.forceMkdir(target.getParentFile()); } InputStream is = null; OutputStream os = null; try { is = resource.getInputStream(); os = new FileOutputStream(target); IOUtils.copyLarge(is, os); } finally { IOUtils.closeQuietly(is); IOUtils.closeQuietly(os); } if (target.length() == 0) { FileUtils.deleteQuietly(target); } } } if (aCache) { classpathFolderCache.put(aClasspathBase, folder); } } return folder; } }  static File getClasspathAsFolder(String aClasspathBase, boolean aCache); static File getUrlAsFile(URL aUrl, boolean aCache); static synchronized File getUrlAsFile(URL aUrl, boolean aCache, boolean aForceTemp); static synchronized File getUrlAsExecutable(URL aUrl, boolean aCache); @Deprecated static InputStream resolveCompressedInputStream(InputStream is, String filename); static URL resolveLocation(String aLocation); static URL resolveLocation(String aLocation, UimaContext aContext); static URL resolveLocation(String aLocation, Object aCaller, UimaContext aContext); static URL resolveLocation(String aLocation, ClassLoader aClassLoader,
            UimaContext aContext);  }
@Test public void testClasspathAsFolder() throws Exception { File file = ResourceUtils .getClasspathAsFolder("classpath:/org/dkpro/core/api", true); List<Path> paths = new ArrayList<Path>(); for (File f : FileUtils.listFiles(file, null, true)) { paths.add(Paths.get(f.getAbsolutePath().substring(file.getAbsolutePath().length()))); } Collections.sort(paths); assertEquals(asList(Paths.get("/resources/CompressionUtilsTest.class"), Paths.get("/resources/MappingProviderTest$1.class"), Paths.get("/resources/MappingProviderTest$2.class"), Paths.get("/resources/MappingProviderTest.class"), Paths.get("/resources/ResourceObjectProviderTest$1.class"), Paths.get("/resources/ResourceObjectProviderTest$2.class"), Paths.get("/resources/ResourceObjectProviderTest$3.class"), Paths.get("/resources/ResourceObjectProviderTest$SharableObjectProvider.class"), Paths.get("/resources/ResourceObjectProviderTest.class"), Paths.get("/resources/ResourceUtilsTest.class")), paths); }