List of utility methods to do File Name Get
String | getFileName(File file) get File Name String filename; String[] parts = file.toString().split(Pattern.quote("\\")); filename = parts[parts.length - 1]; String[] segs = filename.split(Pattern.quote(".")); filename = segs[segs.length - 2]; return filename; |
String | getFileName(File file) get File Name assert (file != null); if (!file.exists()) { return null; String filepath = file.getName(); int i = filepath.lastIndexOf(File.separator); return (i >= 0) ? filepath.substring(i + 1) : filepath; |
String | getFilename(File file) On Windows machines the path contains "\\", however, when converted to a String, this becomes "\". return file.getAbsolutePath().replaceAll("\\\\", "\\\\\\\\"); |
String | getFilename(File file) get Filename return getFilename(file.getName());
|
String | getFilename(File file) return filename without the path. String ext = getExtension(file);
String base = getBase(file);
return setExtension(ext, base);
|
String | getFileName(File file) get File Name if (file.isDirectory()) { return file.getName(); String name = file.getName(); return name.substring(0, name.indexOf(".")); |
String | getFileName(File file) get File Name if (file.isDirectory()) { return file.getName(); } else { String fileType = getFileType(file); if ("unknown".equals(fileType)) { return file.getName(); } else { String fileName = file.getName(); ... |
String | getFileName(File file) get File Name return file.getName();
|
String | getFilename(File file, boolean withExtension) get Filename String[] piece = _splitPathName(file); if (withExtension) { return piece[FILENAME] + piece[EXTENSION]; return piece[FILENAME]; |
String | getFileName(File path) Returns the file name (without extension) given a absolute path. String fName; int idx; fName = path.getName(); if (fName.length() == 0) return null; idx = fName.lastIndexOf('.'); if (idx < 0) return fName; ... |