List of utility methods to do File Extension Name Get
String | getFileExtension(String file) get File Extension String extension = ""; String fileName = new File(file).getName(); int idxOfDot = fileName.lastIndexOf('.'); if (idxOfDot != -1) { extension = fileName.substring(idxOfDot + 1); return extension; |
String | getFileExtension(String fileName) get File Extension int index = fileName.lastIndexOf("."); if (index == -1) return null; return fileName.substring(index + 1); |
String | getFileExtension(String filename) get File Extension return getFileExtension(filename, ""); |
String | getFileExtension(String filename, String defExt) get File Extension if (filename == null || filename.length() == 0) return defExt; int pos = filename.lastIndexOf('.'); if (pos >= 0) { return filename.substring(pos + 1); return defExt; |
String | getFileExtensionFromName(String filename) get File Extension From Name if (filename == null) { return null; int index = indexOfExtension(filename); if (index == -1) { return ""; } else { return filename.substring(index + 1); ... |
String | getFileExtensionFromSource(byte[] picHeader) get File Extension From Source String picExtendName = null; if (picHeader.length >= 2 && (picHeader[0] == 66) && (picHeader[1] == 77)) { picExtendName = "BMP"; } else if (picHeader.length >= 4 && (picHeader[1] == 80) && (picHeader[2] == 78) && (picHeader[3] == 71)) { picExtendName = "PNG"; } else if (picHeader.length >= 6 && (picHeader[0] == 71) ... |
String | getFileExtensionFromUrl(String url) Returns the file extension or an empty string if there is no extension. if (url != null && url.length() > 0) { int query = url.lastIndexOf('?'); if (query > 0) { url = url.substring(0, query); int filenamePos = url.lastIndexOf('/'); String filename = 0 <= filenamePos ? url .substring(filenamePos + 1) : url; ... |
String | getFilenameExtension(String path) get Filename Extension if (path == null) { return null; int extIndex = path.lastIndexOf(EXTENSION_SEPARATOR); if (extIndex == -1) { return null; int folderIndex = path.lastIndexOf(FOLDER_SEPARATOR); ... |
String | getNameMinusExtension(File file) Returns the file's name minus any extension, that is, the part of its name up to (but not including) the last '.' Check.arg().notNull(file); String name = file.getName(); int indexPeriod = name.lastIndexOf('.'); if (indexPeriod == -1) return name; else return name.substring(0, indexPeriod); |
String | getPathExtension(final String path) Returns extension of path without ".". String result = null; if (path != null) { result = ""; if (path.lastIndexOf('.') != -1) { result = path.substring(path.lastIndexOf('.')); if (result.startsWith(".")) { result = result.substring(1); return result; |