List of utility methods to do File Extension Name Get
String | getFileExtension(File file, boolean withDot) Returns extension of specified file. if (file == null) { return null; String path = file.getAbsolutePath(); int dotAt = path.lastIndexOf('.'); if (dotAt < 0) { return null; if (!withDot) { dotAt++; return path.substring(dotAt); |
String | getFileExtension(final File aFile) Returns the "presumed" filename extension (like '.jpg', '.zip') from a given file. String ext = ""; String filename = aFile.getName(); int idx = filename.lastIndexOf('.'); if ((idx >= 0) && (idx < (filename.length() - 1))) { ext = filename.substring(idx + 1).toLowerCase(); if (aFile.exists() && aFile.isDirectory() && !"".equals(ext)) { ext = ""; ... |
String | getFileExtension(final File file) Gets the extension of a filename. if (file == null) { throw new IllegalArgumentException("Unable to get the file extension from 'null'"); final String fileName = file.getName(); final int lastIndexOfDot = fileName.lastIndexOf('.'); if (lastIndexOfDot > 0) { return fileName.substring(lastIndexOfDot + 1); return ""; |
String | getFileExtension(final File file) get File Extension final String ext; if (file != null) { final String scriptFileName = file.getName(); ext = scriptFileName.lastIndexOf('.') == -1 ? "" : scriptFileName.substring(scriptFileName.lastIndexOf('.') + 1, scriptFileName.length()); } else { ext = ""; return ext; |
String | getFileExtension(final String file) Returns the file extension of a file final int lastIndexOf = file.lastIndexOf('.'); if (lastIndexOf == -1) { return ""; return file.substring(lastIndexOf + 1); |
String | getFileExtension(final String fullName) Returns the file extension for the given file name, or the empty string if the file has no extension. Assert.isNotNull(fullName, "fullName must be given!"); final String fileName = new File(fullName).getName(); final int dotIndex = fileName.lastIndexOf('.'); return (dotIndex == -1) ? "" : fileName.substring(dotIndex + 1); |
String | getFileExtension(String file) get File Extension return getFileExtension(new File(file)); |
String | getFileExtension(String filename) get File Extension if (filename != null) { int n = filename.lastIndexOf('.'); if (n >= 0) { return filename.substring(n + 1); return null; |
String | getFileExtension(String fileName) get File Extension int i = fileName.lastIndexOf('.'); int p = Math.max(fileName.lastIndexOf('/'), fileName.lastIndexOf('\\')); if (i > p) { return fileName.substring(i + 1); return ""; |
String | getFileExtension(String filename) exclude "." try { return filename.substring(filename.lastIndexOf(".") + 1); } catch (Exception e) { return null; |