List of utility methods to do File Name Get
String | getFileName(String dir, String name) get File Name String res = dir; if (res.charAt(res.length() - 1) == '/') { res = res.substring(0, res.length() - 1); char[] mm = { File.separatorChar }; String sp = String.copyValueOf(mm); StringTokenizer st = new StringTokenizer(name, "/"); while (st.hasMoreElements()) { ... |
String | getFileName(String f) This method returns the file name of a given file-path which is passed as parameter. String fn = null; int i = f.lastIndexOf(String.valueOf(File.separatorChar)); if (i != -1) { int j = f.lastIndexOf("."); if (j != -1) { try { fn = f.substring(i + 1, j); } catch (IndexOutOfBoundsException ex) { ... |
String | getFileName(String fileName) get File Name if (isEmpty(fileName)) { return null; return fileName.substring(0, fileName.lastIndexOf(".")); |
String | getFileName(String filePath) An OS independent getName alternative. String tempFileName = filePath; int slash1 = tempFileName.lastIndexOf("/"); int slash2 = tempFileName.lastIndexOf("\\"); int lastSlashIndex = Math.max(slash1, slash2); if (lastSlashIndex != -1) { tempFileName = tempFileName.substring(lastSlashIndex + 1); return tempFileName; ... |
String | getFileName(String filePath) get the file displayName from a file path; if (filePath == null) { return null; } else { int index = filePath.lastIndexOf('\\'); if (index >= 0) { return filePath.substring(index + 1); } else { index = filePath.lastIndexOf('/'); ... |
String | getFileName(String filepath) get File Name if (filepath == null) { return null; File f = toFile(filepath); return f.getName(); |
String | getFileName(String filePath) get File Name File f = new File(filePath); if (f.exists()) { return f.getName(); } else { return null; |
String | getFileName(String filePath) Returns only the fileName of the filePath. int lastIndex = filePath.lastIndexOf(File.separator); String result = filePath.substring(lastIndex + 1, filePath.length()); return result; |
String | getFilename(String filePath) get Filename File f = new File(filePath); return f.getName(); |
String | getFileName(String filePath) The file name of the specified file path is returned. File file = new File(filePath); String fileName = file.getName(); int postion = fileName.lastIndexOf('.'); if (postion == -1) return fileName; return fileName.substring(0, postion); |