示例#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);
      }
    }
  }