public class FileHandler { public FileHandler() { }
public List findFiles(String path, boolean showOnlyFiles) { List fileList = new LinkedList(); find(path, fileList); return fileList; }
private void find(String path, List result) { File dir = new File(path); String[] dirlist = dir.list(); if(dirlist != null) { for (int i = 0; i < dirlist.length; i++) { // System.getProperty("file.separator") returnerer \ paa Windows og / paa // Unix/Linux String fnm = dir + System.getProperty("file.separator") + dirlist[i]; if (new File(fnm).isFile()) result.add(new String(fnm)); if (new File(fnm).isDirectory()) find(fnm, result); } } }
public class FileHandler { public FileHandler() { }
public List findFiles(String path, boolean showOnlyFiles) { List fileList = new LinkedList(); find(path, fileList); return fileList; }
private void find(String path, List result) { File dir = new File(path); String[] dirlist = dir.list( new Filter() ); // HER if(dirlist != null) { for (int i = 0; i < dirlist.length; i++) { // System.getProperty("file.separator") returnerer \ paa Windows og / paa // Unix/Linux String fnm = dir + System.getProperty("file.separator") + dirlist[i]; if (new File(fnm).isFile()) result.add(new String(fnm)); if (new File(fnm).isDirectory()) find(fnm, result); } } }
private class Filter implements FilenameFilter{ public Filter(){ }
public boolean accept(File dir, String name) { if(name.endsWith(".dat")) return true;
public class FileHandler implements FilenameFilter{{ public FileHandler() { }
public List findFiles(String path, boolean showOnlyFiles) { List fileList = new LinkedList(); find(path, fileList); return fileList; }
private void find(String path, List result) { File dir = new File(path); String[] dirlist = dir.list( this ); // HER if(dirlist != null) { for (int i = 0; i < dirlist.length; i++) { // System.getProperty("file.separator") returnerer \ paa Windows og / paa // Unix/Linux String fnm = dir + System.getProperty("file.separator") + dirlist[i]; if (new File(fnm).isFile()) result.add(new String(fnm)); if (new File(fnm).isDirectory()) find(fnm, result); } } }
public boolean accept(File dir, String name) { if(name.endsWith(".dat")) return true;
public class FileHandler implements FilenameFilter{{ public FileHandler() { }
public FileHandler(String extension) { this.ext = extension; }
public List findFiles(String path, boolean showOnlyFiles) { List fileList = new LinkedList(); find(path, fileList); return fileList; }
private void find(String path, List result) { File dir = new File(path); String[] dirlist = dir.list( this ); // HER if(dirlist != null) { for (int i = 0; i < dirlist.length; i++) { // System.getProperty("file.separator") returnerer \ paa Windows og / paa // Unix/Linux String fnm = dir + System.getProperty("file.separator") + dirlist[i]; if (new File(fnm).isFile()) result.add(new String(fnm)); if (new File(fnm).isDirectory()) find(fnm, result); } } }
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.