Java Directory to File List getAllFilePath(String filedir)

Here you can find the source of getAllFilePath(String filedir)

Description

get All File Path

License

Apache License

Declaration

@SuppressWarnings("rawtypes")
    private static List getAllFilePath(String filedir) 

Method Source Code

//package com.java2s;
/**//from w ww.  ja v a  2  s  .c  om
 * Automatic Subtitle Downloader
 * http://code.google.com/p/autosubdown/
 * 
 * Copyright 2010-2011 Raphael Medeiros.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 */

import java.io.File;

import java.util.ArrayList;
import java.util.List;

public class Main {
    @SuppressWarnings("rawtypes")
    private static List getAllFilePath(String filedir) {
        File f = new File(filedir);
        List<File> l = new ArrayList<File>();
        getFilePaths(f, l);
        return l;
    }

    private static void getFilePaths(File dir, List<File> l) {
        if (dir.isDirectory()) {
            File d[] = dir.listFiles();
            for (int i = 0; i < d.length; i++) {
                getFilePaths(d[i], l);
            }
        } else if (dir.isFile()) {
            l.add(dir);
        }
    }
}

Related

  1. getAllFileNames(File basedir, String path)
  2. getAllFileNames(String path, String suffix, boolean isDepth)
  3. getAllFileNamesByPath(String path)
  4. getAllFileNamesInDir(String folderName)
  5. getAllFileNamesWithExtension(String directory, final String extension)
  6. getAllFiles(File dir)
  7. getAllFiles(File dir)
  8. getAllFiles(File dir, List fileList)
  9. getAllFiles(File dir, List fileList)