List of utility methods to do File Extension Name Extract
String | extractFileExtension(String path) Extract the file extension from the given URI path. int end = path.indexOf('?'); if (end == -1) { end = path.indexOf('#'); if (end == -1) { end = path.length(); int begin = path.lastIndexOf('/', end) + 1; ... |
String | extractFileExtensionFromPath(String path) Extracts file's extension in ".extension" format. if (path != null) { if (path.isEmpty()) { throw new IllegalArgumentException("File path can't be empty"); } else { throw new NullPointerException("File path can't be null"); String lowercaseName = path.toLowerCase(); ... |
String | getFileExtension(File f) get File Extension String fileName = f.getName(); String fileExtension = fileName; int lastPos = fileName.lastIndexOf('.'); if (lastPos > 0 && lastPos < (fileName.length() - 1)) { fileExtension = fileName.substring(lastPos + 1).toLowerCase(); return fileExtension; |
String | getFileExtension(File file) get File Extension String filename = file.getName().trim().toLowerCase(); if (filename.length() == 0) return ""; if (filename.charAt(filename.length() - 1) == '.') filename = filename.substring(0, filename.length() - 1); int lastPointIndex = filename.lastIndexOf('.'); if (lastPointIndex < 0) return ""; ... |
String | getFileExtension(File file) get File Extension String path = file.getPath(); Matcher matcher = FileNamePattern.matcher(path); if (matcher.find()) { return matcher.group(2); return null; |
String | getFileExtension(File file) get File Extension return getFileExtension(file.getPath());
|
String | getFileExtension(File file) get File Extension if (file == null) { return null; return getFileExtension(file.getName()); |
String | getFileExtension(File file) get File Extension String name = file.getName(); int idx = name.lastIndexOf('.'); if (!file.isDirectory() && idx != -1) { return name.substring(idx + 1, name.length()).toLowerCase(); return ""; |
String | getFileExtension(File file) returns a file's extension/type, excluding the extension separator (by default a period '.') return getFileExtension(file.getName());
|
String | getFileExtension(File file) get File Extension if (file != null && file.exists()) { return getFileExtension(file.getAbsolutePath()); } else if (file == null) throw new NullPointerException("File is null"); else throw new FileNotFoundException("File [" + file.getAbsolutePath() + "] does not seem to exist."); |