List of utility methods to do URL to File Name
File | getFile(URL aURL) Returns the URL as a file. if (aURL.getProtocol().equals("jar")) { String urls = aURL.toExternalForm(); int sep = urls.indexOf('!'); urls = urls.substring(4, sep); try { aURL = new URL(urls); } catch (Exception e) { throw new RuntimeException(e); ... |
File | getFile(URL resourceUrl, String description) get File if (!URL_PROTOCOL_FILE.equals(resourceUrl.getProtocol())) { throw new FileNotFoundException(description + "->" + resourceUrl); try { return new File(toURI(resourceUrl).getSchemeSpecificPart()); } catch (URISyntaxException ex) { return new File(resourceUrl.getFile()); |
File | getFile(URL resourceUrl, String description) Resolve the given resource URL to a java.io.File , i.e.
if (!URL_PROTOCOL_FILE.equals(resourceUrl.getProtocol())) { throw new FileNotFoundException(description + " cannot be resolved to absolute file path " + "because it does not reside in the file system: " + resourceUrl); try { return new File(resourceUrl.toURI().getSchemeSpecificPart()); } catch (URISyntaxException ex) { return new File(resourceUrl.getFile()); ... |
File | getFile(URL resourceUrl, String description) Resolve the given resource URL to a java.io.File , i.e.
if (!URL_PROTOCOL_FILE.equals(resourceUrl.getProtocol())) { throw new FileNotFoundException(description + " cannot be resolved to absolute file path " + "because it does not reside in the file system: " + resourceUrl); return new File(URLDecoder.decode(resourceUrl.getFile())); |
File | getFile(URL resourceUrl, String description) get File if (resourceUrl == null) { throw new IllegalArgumentException("Resource URL must not be null"); if (!URL_PROTOCOL_FILE.equals(resourceUrl.getProtocol())) { throw new FileNotFoundException(description + " cannot be resolved to absolute file path " + "because it does not reside in the file system: " + resourceUrl); try { ... |
File | getFile(URL resourceUrl, String description) Resolve the given resource URL to a java.io.File , i.e.
if (!URL_PROTOCOL_FILE.equals(resourceUrl.getProtocol())) { throw new FileNotFoundException(description + " cannot be resolved to absolute file path " + "because it does not reside in the file system: " + resourceUrl); try { return new File(toURI(resourceUrl).getSchemeSpecificPart()); } catch (URISyntaxException ex) { return new File(resourceUrl.getFile()); ... |
File | getFile(URL ressource) get File StringBuilder file = new StringBuilder(); String host = ressource.getHost(), path = ressource.getPath(); if (host != null && !host.isEmpty()) file.append(File.separatorChar).append(File.separatorChar).append(host); return new File(file.append(path.split("!", 2)[0]).toString()); |
File | getFile(URL url) For local file conversion. File f = null; try { f = new File(url.toURI()); } catch (URISyntaxException e) { f = new File(url.getPath()); return f; |
String | getFile(URL url) get File String path = url.getPath(); int index = path.lastIndexOf('/'); String file = index == -1 ? path : path.substring(index + 1); return file; |
File | getFile(URL url) get File return new File(getFilePath(url)); |