/** * gets the FileName (with extension) of an URL (better than commons-io) * * @param url * the to get the file name from * @return BaseName */ public static String getFilename(String url) { return getFileNameArray(url)[2]; }
/** * gets the BaseName (w/o extension) of an URL (better than commons-io) * * @param url * the to get the base name from * @return BaseName */ public static String getBasename(String url) { return getFileNameArray(url)[0]; }
/** * gets the Extension of an URL (better than commons-io) * * @param url * the to get the extension from * @return BaseName */ public static String getExtension(String url) { return getFileNameArray(url)[1]; }
/** * Returns file extension from url. * * @param url * the url * @return file extension or empty string * @throws URISyntaxException * if url is not valid */ public static String getFileExtension(String url) throws URISyntaxException { String ext = getURIEncoded(url).getPath(); if (ext == null || ext.isEmpty() || !ext.contains(".")) { LOGGER.warn("Url " + url + " has no extension!"); return ""; } else { ext = getFileNameArray(url)[1]; return ext; } }