예제 #1
0
파일: Base.java 프로젝트: bjj/ReplicatorG
 public static String[] listFiles(File folder, boolean relative) {
   String path = folder.getAbsolutePath();
   Vector<String> vector = new Vector<String>();
   addToFileList(relative ? (path + File.separator) : "", path, vector);
   String outgoing[] = new String[vector.size()];
   vector.copyInto(outgoing);
   return outgoing;
 }
예제 #2
0
파일: Base.java 프로젝트: bjj/ReplicatorG
  protected static void addToFileList(String basePath, String path, Vector<String> fileList) {
    File folder = new File(path);
    String list[] = folder.list();
    if (list == null) return;

    for (int i = 0; i < list.length; i++) {
      if (list[i].charAt(0) == '.') continue;

      File file = new File(path, list[i]);
      String newPath = file.getAbsolutePath();
      if (newPath.startsWith(basePath)) {
        newPath = newPath.substring(basePath.length());
      }
      fileList.add(newPath);
      if (file.isDirectory()) {
        addToFileList(basePath, newPath, fileList);
      }
    }
  }