java数据结构
用数据结构里的递归算法怎么去从电脑上获取资源管理器里面的文件要求按树状结构输出?
Java code:
public class FindFile {
public void findFile(File f,String fileType){//f为目录文件,fileType为文件类型(后缀postfix),
File[] ff=f.listFiles();
for(File f1:ff){
if(f1.isFile()&&f1.getName().endsWith(fileType)){//文件名以什么结尾就是什么文件
System.out.println(f1);
}
if(f1.isDirectory()){
findFile(f1,fileType);
}
}
}
public static void main(String[] args){
FindFile ff=new FindFile();
ff.findFile(new File("D:\\文本文档"), ".txt");
}
}
不是树状输出,你自己调整下
谢谢 不是理想的
import java.io.File;
public class TestListFile {
private File file;
public TestListFile(String filePath) {
file = new File(filePath);
listFile(file,0);
}
public void listFile(File tmpFile,int indent) {
if(tmpFile.isFile() == true) {
printPrefix(indent);
System.out.println(tmpFile.getName());
return;
&nbs
相关问答:
我目前在本地的linux上写了一个swing的界面,想通过这个界面来控制其它电脑的linux重启。
我知道用Runtime.getRuntime().exec("shutdown -r");可以控制本机Linux重启,但是怎么控制远程的linux重启呢? ......
不知道是什么原因,我该如何处理,请大虾们指教了,小弟在此谢过。。。。
错误信息如下:
The program being debugged was signaled while in a function called from GDB.
GDB has restored the context t ......
这种页面方式如何在struts里实现
<form id="form1" name="form1" method="post" action="a.jsp" >
<% String myscore = request.getParameter ......
想学习下J2SE下的MVC架构。希望大家推荐点资源给我,最好有MVC实例的。
J2SE的不会
J2EE的到是知道点,你先从JSP+servlet+javaBean学习吧,掌握了之后,再学习学习struts!
引用
J2SE的不会
J2EE的 ......
我用c++中的struct来存储数据,该struct中有String,double.我现在想用java对它进行读取,
怎么读??
我用了String和类两种,都不行(类中的类型和struct中定义类型相同).
得用byte[]来接,然后再解析!
这 ......