List of utility methods to do URL to File Name
String | getFileName(URLConnection urlC) Returns the file name associated to an url connection. The result is not a path but just a file name. String fileName = null; String contentDisposition = urlC.getHeaderField("content-disposition"); if (contentDisposition != null) { fileName = extractFileNameFromContentDisposition(contentDisposition); if (fileName == null) { StringTokenizer st = new StringTokenizer(urlC.getURL().getFile(), "/"); while (st.hasMoreTokens()) ... |
String | getFileName2(String url) get File Name String file = null; try { file = (new File((new URI(url)).getPath())).getName(); System.out.println("File name: " + file); } catch (Exception var3) { ; if (file == null || file.length() < 1) { ... |
String[] | getFileNameArray(String url) get the correct name/extension/filename of url (even with parameters! String[] ret = new String[] { "", "", "" }; String filename = ""; String path = ""; try { url = getURIEncoded(url).toString(); path = new URL(url).getPath(); } catch (Exception e) { return ret; ... |
String | getFileNameFromContentDisposition(URLConnection connection) get File Name From Content Disposition String contentDispositionHeaderValue = connection.getHeaderField(CONTENT_DISPOSITION_HEADER); if (contentDispositionHeaderValue != null) { Matcher matcher = CONTENT_DISPOSITION_FILE_NAME_PATTERN.matcher(contentDispositionHeaderValue); if (matcher.matches()) { return matcher.group(CONTENT_DISPOSITION_FILE_NAME_PATTERN_GROUP); return null; ... |
String | getFileNameFromUrl(URL inputUrl) get File Name From Url String urlStr = inputUrl.toString(); String fileName = urlStr.substring(urlStr.lastIndexOf("/") + 1); return fileName; |
String | getFileNameFromUrl(URL inputUrl) get File Name From Url String urlStr = inputUrl.toString(); String fileName = urlStr.substring(urlStr.lastIndexOf("/") + 1); return fileName; |
String | URIToFilename(String str) Fixes a platform dependent filename to standard URI form. if (str.length() >= 3) { if (str.charAt(0) == '/' && str.charAt(2) == ':') { char ch1 = Character.toUpperCase(str.charAt(1)); if (ch1 >= 'A' && ch1 <= 'Z') str = str.substring(1); str = str.replace('/', java.io.File.separatorChar); ... |