您的位置:首页 > 其它

打印所有文件路径

2011-05-17 01:37 239 查看
import java.io.File;

public class TestAllFile{
// 打印指定目录下的所有文件路径和文件名
public static void f(String dir){
try{
File f = new File(dir);
String[] fileList = null;
if(f.isDirectory()){
fileList = f.list();
for(int i=0; i<fileList.length; i++){
f(dir + "//" + fileList[i]);
}
}else{
System.out.println(dir);
}
}catch(Exception e){

}
}

public static void main (String[] args) {

String s = "E:";
f(s);
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐