'디렉토리 리스트'에 해당되는 글 1건

  1. 2010/02/11 visualp 파일 목록, 디렉토리 목록 구하기 ,Listing the Files or Subdirectories in a Directory
package com.ubibada.common.util;
import java.io.File;
import java.io.FileFilter;
import java.io.FilenameFilter;
import java.util.ArrayList;
public class FileUtil {
 
 private ArrayList list=null;
 private File dir;
 private File[] dirlist;
 
 public FileUtil(){
  list = new ArrayList();
 }
 
 //directory filter
 private FileFilter getDirectoryFilter(){
  FileFilter fileFilter = new FileFilter() {
      public boolean accept(File file) {
          return file.isDirectory();
      }
  };
  return fileFilter;
 }
 
 //file filter
 private FilenameFilter getFileFilter(){
  FilenameFilter filter = new FilenameFilter() {
      public boolean accept(File dir, String name) {
          return !name.startsWith(".");
      }
  };
  return filter;
 }
 
 
 public ArrayList getdirlist(String path){
  dir = new File(path);
  conv_fileArry_to_list(dir.listFiles(getFileFilter()));
  return list;
 }
 
 public ArrayList getDirectoryList(String path){
  dir = new File(path);
  conv_fileArry_to_list(dir.listFiles(getDirectoryFilter()));
  return list;
 }
 
 private void conv_fileArry_to_list(File[] dirlist){
  this.list.clear();
  for (File flist : dirlist){
   this.list.add(flist.getName());
  }
 }
}
2010/02/11 09:46 2010/02/11 09:46
받은 트랙백이 없고, 댓글이 없습니다.

댓글+트랙백 RSS :: http://blog.visualp.com/rss/response/200

댓글+트랙백 ATOM :: http://blog.visualp.com/atom/response/200