ResourceUtils { public static synchronized File getUrlAsExecutable(URL aUrl, boolean aCache) throws IOException { File file; synchronized (urlFileCache) { file = urlFileCache.get(aUrl.toString()); if (!aCache || (file == null) || !file.exists()) { String name = FilenameUtils.getBaseName(aUrl.getPath()); file = File.createTempFile(name, ".temp"); file.setExecutable(true); if (!file.canExecute()) { StringBuilder errorMessage = new StringBuilder(128); errorMessage.append("Tried to use temporary folder, but seems it is not " + "executable. Please check the permissions rights from your " + "temporary folder.\n"); if (isEnvironmentVariableDefined(XDG_RUNTIME_DIR_ENV_VAR, errorMessage) && checkFolderPermissions(errorMessage, System.getenv(XDG_RUNTIME_DIR_ENV_VAR))) { file = getFileAsExecutable(aUrl, System.getenv(XDG_RUNTIME_DIR_ENV_VAR)); } else if (isEnvironmentVariableDefined(DKPRO_HOME_ENV_VAR, errorMessage) && checkFolderPermissions(errorMessage, System.getenv(DKPRO_HOME_ENV_VAR) + File.separator + "temp")) { file = getFileAsExecutable(aUrl, System.getenv(DKPRO_HOME_ENV_VAR) + File.separator + "temp"); } else { if (!isUserHomeDefined(errorMessage) || !checkFolderPermissions(errorMessage, System.getProperty("user.home") + File.separator + ".dkpro" + File.separator + "temp")) { throw new IOException(errorMessage.toString()); } file = getFileAsExecutable(aUrl, System.getProperty("user.home") + File.separator + ".dkpro" + File.separator + "temp"); } } file.deleteOnExit(); InputStream inputStream = null; OutputStream outputStream = null; try { inputStream = aUrl.openStream(); outputStream = new FileOutputStream(file); copy(inputStream, outputStream); } finally { closeQuietly(inputStream); closeQuietly(outputStream); } if (aCache) { urlFileCache.put(aUrl.toString(), file); } } } return file; }  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 testGetUrlAsExecutable() throws IOException { URL url = new URL("jar:file:src/test/resources/testfiles.zip!/testfiles/" + "FileSetCollectionReaderBase.class"); File file = ResourceUtils.getUrlAsExecutable(url, false); assertThat(file.getName()).endsWith("temp"); URL url2 = new URL("jar:file:src/test/resources/testfiles.zip!/testfiles/" + "ResourceCollectionReaderBase.class"); file = ResourceUtils.getUrlAsExecutable(url2, true); assertThat(file.getName()).endsWith("temp"); }