package Li;
import java.io.*;
public class FileDemo {
public static void main(String[] args) throws IOException{
// TODO Auto-generated method stub
String s="";
File f = new File("D:\\kugou", s);
CreateFile(f,s);
}
public static void CreateFile(File file, String bs) throws IOException
{
String temp = bs;
BufferedWriter bfw = new BufferedWriter(new FileWriter("F:\\BaiduYunDownload\\新建文件夹\\ser.txt"));
File[] str = file.listFiles();
for(File f : str)
{
bfw.write(bs);
bfw.write(f.getName());
bfw.newLine();
//bfw.flush();
if(f.isDirectory())
{
bs += "----";
CreateFile(f, bs);
bs = temp;
}
}
bfw.close();
}
}
|
|