package com.runant.utils;
import java.io.*;
import java.util.*;
public class FileUtils[align=left][/align] {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
String path = "C:\\test\\51job";
List<String> list = readfile(path);
int count = 0;
String fileName = null;
if (list != null && list.size() > 0) {
for (; count < list.size(); count++) {
//TODO
System.out.println(list.get(count)) ; }
}
System.err.println("处理文件数量 :" + count );
}
public static List<String> readfile(String filepath)
throws FileNotFoundException {
List<String> list = new ArrayList<String>();
File file = null;
file = new File(filepath);
if (file.isDirectory()) {
String[] filelist = file.list();
for (int i = 0; i < filelist.length; i++) {
File readfile = new File(filepath + "/" + filelist[i]);
if (!readfile.isDirectory()) {
list.add(readfile.getAbsolutePath());
} else if (readfile.isDirectory()) {
list.addAll(0, readfile(filepath + "/" + filelist[i]));
}
}
}
return list;
}
}