List of utility methods to do File Name Get
String[] | getFileNameStartingWith(String directory, String prefix) get an array of all files in the given directory, with given prefix Vector<String> vector = new Vector<String>(); File f = new File(directory); File[] files = f.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].getName().startsWith(prefix)) { vector.add(files[i].getName()); String[] toReturn = new String[vector.size()]; vector.toArray(toReturn); return toReturn; |
String | getFilenameSuffix(final File file) Gets the filename suffix or null if no suffix exists or the given file object is a directory. if (!file.isDirectory()) { final String fileName = file.getAbsolutePath(); final int ext_index = fileName.lastIndexOf("."); final String fileNameSuffix; if (ext_index != -1) { fileNameSuffix = fileName.substring(ext_index, fileName.length()); } else { fileNameSuffix = null; ... |
ArrayList | getFileNameUtil(String dataPath) get File Name Util ArrayList<String> fileName = new ArrayList<>(); File file = new File(dataPath); File[] files = file.listFiles(); if (files != null) { for (File file1 : files) { if (file1.isDirectory()) { getFileNameUtil(file1.getPath()); } else { ... |
File | getFileNameWithAddedExtension(File parent, File f, String ext) get File Name With Added Extension File ff = new File(parent, f.getName() + ext); if (ff.exists()) { return ff; return null; |
File | getFileNameWithNewExtension(File parent, File file, String ext) get File Name With New Extension return isFileExists(new File(parent, file.getName()), ext); |
String | getFilenameWithoutAnyExtension(File file) Gets the name of the supplied file without any extension. return getFilenameWithoutAnyExtension(file.getName());
|
String | getFileNameWithoutExt(File file) get File Name Without Ext if (file.getName().lastIndexOf(".") == -1) return file.getName(); return file.getName().substring(0, file.getName().lastIndexOf(".")); |
String | getFileNameWithoutExt(File filePath) get the file name without extension if (filePath == null) return null; String fileName = filePath.getName(); if (fileName == null) return null; return (fileName.substring(0, fileName.lastIndexOf("."))); |
String | getFileNameWithoutExt(String file) get File Name Without Ext return file.substring(getSeparatorIndex(file), getDotIndex(file));
|
String | GetFileNameWithoutExt(String file_path) Returns the name of the file without the extension int pos = file_path.lastIndexOf(FILE_EXTENSION_SEPARATOR); int pos2 = file_path.lastIndexOf(GetDirectorySeparator()); if (pos2 < pos) return file_path.substring(0, pos); else return file_path; |