遍历文件目录
来源:互联网 发布:淘宝钻号哪里看 编辑:程序博客网 时间:2024/04/28 21:41
import java.io.*;
import java.util.*;
public class Read {
ArrayList nameList=new ArrayList();
public void getSubFile(String FileName) {
File parentF = new File(FileName);
if (!parentF.exists()) {
System.out.println("文件或目录不存在");
return; }
if (parentF.isFile()) {
nameList.add(parentF.getAbsolutePath());
return; }
String[] subFiles = parentF.list();
for (int i = 0; i < subFiles.length; i++) {
getSubFile(parentF.getAbsolutePath() + "/" + subFiles[i]);
}
//打印输出文件目录结构
Iterator it=nameList.iterator();
while(it.hasNext()){
System.out.println(it.next());
}
// Object[] x=nameList.toArray();
// for(int j=0;j<x.length;j++){
// System.out.println(x[j]);
// }
// for(int j=0;j<nameList.size();j++){
// System.out.println(nameList.get(j));
// }
}
public static void main(String[] args) {
// TODO Auto-generated method stub
//Read read=new Read();
//read.getSubFile("d:/ant");
System.out.println("Please Input a path:");
try{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
ReadAll ra=new ReadAll();
ra.GetSubfiles(br.readLine());
}catch(Exception e){
e.printStackTrace();
}
}
import java.util.*;
public class Read {
ArrayList nameList=new ArrayList();
public void getSubFile(String FileName) {
File parentF = new File(FileName);
if (!parentF.exists()) {
System.out.println("文件或目录不存在");
return; }
if (parentF.isFile()) {
nameList.add(parentF.getAbsolutePath());
return; }
String[] subFiles = parentF.list();
for (int i = 0; i < subFiles.length; i++) {
getSubFile(parentF.getAbsolutePath() + "/" + subFiles[i]);
}
//打印输出文件目录结构
Iterator it=nameList.iterator();
while(it.hasNext()){
System.out.println(it.next());
}
// Object[] x=nameList.toArray();
// for(int j=0;j<x.length;j++){
// System.out.println(x[j]);
// }
// for(int j=0;j<nameList.size();j++){
// System.out.println(nameList.get(j));
// }
}
public static void main(String[] args) {
// TODO Auto-generated method stub
//Read read=new Read();
//read.getSubFile("d:/ant");
System.out.println("Please Input a path:");
try{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
ReadAll ra=new ReadAll();
ra.GetSubfiles(br.readLine());
}catch(Exception e){
e.printStackTrace();
}
}
- JSP遍历文件目录
- 遍历文件目录
- CFileFind 遍历文件目录
- 递归遍历目录文件
- 遍历文件目录
- 遍历目录得到文件
- 遍历目录所有文件
- 遍历目录查找文件
- 遍历文件和目录
- C#遍历文件目录
- air 遍历目录 文件
- VB遍历目录文件
- 递归遍历目录文件
- python 文件目录遍历
- opencv 目录文件遍历
- 遍历文件目录
- opencv 目录文件遍历
- 遍历文件目录源代码
- XML 学习 (1) —— 译自W3C教程
- 触发器同步表
- 数据库邮件一二三
- 遭遇地震
- 基于 JFace Text Framework 构建全功能代码编辑器: 第 9 部分:Template
- 遍历文件目录
- 用javascript实现级联式下拉选框|用javascript实现省,市下拉级联
- 订报纸引发的设计模式---观察者模式
- 订报纸引发的设计模式---观察者模式
- NetBeans平台中打开文件的写法
- Microsoft adCenter Analytics统计与Google Analytics、雅虎统计对比
- 模拟表单向domino post大容量的数据
- 亲历5.12地震
- 用nohup命令让Linux下程序永远在后台执行