List of utility methods to do File Name Get
String[] | getFilenames(String dirctory) get Filenames File dir = new File(dirctory); File[] fileArray = dir.listFiles(); String[] filenames = new String[fileArray.length]; for (int i = 0; i < fileArray.length; i++) { if (fileArray[i].isDirectory()) { filenames[i] = "[" + fileArray[i].getName() + "]"; } else { filenames[i] = fileArray[i].getName(); ... |
Collection | getFileNames(String directory, String file) get File Names if (isArchive(file)) { try { ZipFile zip = new ZipFile(new File(directory + System.getProperty("file.separator") + file)); Enumeration<ZipEntry> entries = (Enumeration<ZipEntry>) zip.entries(); while (entries.hasMoreElements()) { ZipEntry entry = (ZipEntry) entries.nextElement(); if (isArchive(entry.getName())) { return unzipZipFile(zip, directory); ... |
String[] | getFileNames(String dirPath) get File Names return getFileNames(dirPath, null);
|
String[] | getFilenames(String filenames) get file names from the name/dir string String[] aryNames = filenames.split(","); List<String> list = new ArrayList<>(); for (String s : aryNames) { File path = new File(s.trim()); if (path.isDirectory()) { path.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { ... |
String[] | getFileNames(String path, boolean withFullPath) Returns a string array of file names in a path directory, with or without the full path File dir = new File(path); String[] children = dir.list(); if (children == null) { return null; FilenameFilter filter = new FilenameFilter() { @Override public boolean accept(File dir, String name) { ... |
String[] | getFileNames_STR(String path) get File NameSTR List<File> al = getFiles(path); String[] fl = null; if (al != null && !al.isEmpty()) { fl = new String[al.size()]; for (int i = 0; i < al.size(); i++) { fl[i] = al.get(i).getName(); return fl; |
String[] | getFileNamesFromDir(File rootDir, String indexName) Returns the list of file names in the specified directory. File indexDir = new File(rootDir.getAbsoluteFile(), indexName); assert indexDir.exists(); String[] fileNames = indexDir.list(); assert fileNames.length > 0; return fileNames; |
ArrayList | getFileNamesInJar(File source, String folder, String extension) get File Names In Jar ArrayList<String> list = new ArrayList(); try { JarFile jarFile = new JarFile(source); Enumeration e = jarFile.entries(); while (e.hasMoreElements()) { JarEntry je = (JarEntry) e.nextElement(); if (je.isDirectory() || !je.getName().endsWith(extension) || !je.getName().startsWith(folder)) { continue; ... |
List | getFileNamesOld(File zipFile) http://www.java2novice.com/java-collections-and-util/zip/file-list/ List<String> filenames = new ArrayList<>(); ZipFile z; try { z = new ZipFile(zipFile); Enumeration<? extends ZipEntry> en = z.entries(); while (en.hasMoreElements()) { ZipEntry ze = en.nextElement(); filenames.add(ze.getName()); ... |
String[] | getFileNamesRecursive(final String pDataDir, final FilenameFilter pFilter, final int pMaxFiles) Do a recursive file find. final File currentDir = new File(pDataDir); if (!isDir(currentDir)) { throw new IllegalStateException("Not a dir: " + pDataDir); final LinkedList<String> files = new LinkedList<String>(); final File[] listFiles = currentDir.listFiles(); if (listFiles != null) { for (final File listFile : listFiles) { ... |