你那个type没看出有啥用,给你改了
import java.io.File;
import java.util.Vector;
public class A {
public static void recursion(String root, Vector
File file = new File(root);
File[] subFile = file.listFiles();
for (int i = 0; i < subFile.length; i++) {
if (subFile[i].isDirectory()) {
recursion(subFile[i].getAbsolutePath(), vecFile);
} else {
String filename = subFile[i].getName();
vecFile.add(filename);
}
}
}
public static void main(String[] args) {
Vector
recursion("E:/A", vecFile);
for (String fileName : vecFile) {
System.out.println(fileName);
}
}
}
=================
文件名都给你打出来了,你还想咋处理????
=================
得不到,文件名只不过是一个字符串,没有任何实际意义,除非得到文件名的时候得到文件大小。我给你改了下,Vector里放的是File而不是文件名了,你想干啥都行了
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Vector;
public class A {
public static void recursion(String root, Vector
File file = new File(root);
File[] subFile = file.listFiles();
for (int i = 0; i < subFile.length; i++) {
if (subFile[i].isDirectory()) {
recursion(subFile[i].getAbsolutePath(), vecFile);
} else {
vecFile.add(subFile[i]);
}
}
}
public static void main(String[] args) throws FileNotFoundException, IOException {
Vector
recursion("E:/A", vecFile);
for (File file : vecFile) {
System.out.println(file.getName() + " " + new FileInputStream(file).available());
}
}
}