- import java.io.*;
-
- class IOTest
-
- {
-
- public static void main(String[] args) throws IOException
-
- {
-
- File dir = new File("F:\\javafile");
- BufferedWriter bufw = new BufferedWriter(new FileWriter("a.txt"));
- showDir(dir,bufw);
- bufw.close();
-
- }
-
- public static void showDir(File dir,BufferedWriter out)throws IOException
-
- {
-
- File[] files = dir.listFiles();
-
-
-
-
- for(File file : files)
-
- {
-
- if(file.isDirectory())
-
- showDir(file,out);
-
- else
-
- {
-
- out.write(file.toString());
-
- out.newLine();
-
- out.flush();
-
- }
-
- }
-
- }
-
- }
复制代码 |