Here you can find the source of getFilesByPath(String toDir)
Parameter | Description |
---|---|
toDir | a parameter |
Parameter | Description |
---|---|
Exception | an exception |
public static List getFilesByPath(String toDir) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.File; import java.util.ArrayList; import java.util.List; public class Main { /**/* w w w. ja va 2 s .co m*/ * get all file in a folder * @param toDir * @return * @throws Exception */ public static List getFilesByPath(String toDir) throws Exception { List fileList = new ArrayList(); File dir = new File(toDir); File[] files = dir.listFiles(); String podOrderDir = toDir; System.out.println(podOrderDir); System.out.println("size:" + files.length); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { podOrderDir = files[i].getPath(); fileList.addAll(getFilesByPath(podOrderDir)); } else { fileList.add(toDir + File.separator + files[i].getName()); } } return fileList; } }