level 11
朕不灭
楼主
import java.io.PrintWriter;
public class Test3 {
public static void main(String[] args) throws IOException {
File dirPath = new File("D:\\moniceshitibefore81");
File destPath = new File("result.txt");
copyPathToFile(dirPath, destPath);
}
private static void copyPathToFile(File dirPath, File destPath) throws IOException {
File[] files = dirPath.listFiles();
PrintWriter out = new PrintWriter(new FileWriter(destPath), true);
for (File file : files) {
if (file.isDirectory()) {
copyPathToFile(file, destPath);
} else if (file.isFile() && file.getName().endsWith(".java")) {
out.println(file.getAbsolutePath()+true);
System.out.println(file);
}
}
out.close();
}
}
【冒泡】名字被和谐了 2018/7/31 14:07:35
大佬看下
【冒泡】名字被和谐了 2018/7/31 14:08:06
为什么我输出的只有最后一个文件夹的文件
你撤回了一条消息
【冒泡】名字被和谐了 2018/7/31 14:09:08
【冒泡】名字被和谐了 2018/7/31 14:09:23
2018年07月31日 06点07分
1
public class Test3 {
public static void main(String[] args) throws IOException {
File dirPath = new File("D:\\moniceshitibefore81");
File destPath = new File("result.txt");
copyPathToFile(dirPath, destPath);
}
private static void copyPathToFile(File dirPath, File destPath) throws IOException {
File[] files = dirPath.listFiles();
PrintWriter out = new PrintWriter(new FileWriter(destPath), true);
for (File file : files) {
if (file.isDirectory()) {
copyPathToFile(file, destPath);
} else if (file.isFile() && file.getName().endsWith(".java")) {
out.println(file.getAbsolutePath()+true);
System.out.println(file);
}
}
out.close();
}
}
【冒泡】名字被和谐了 2018/7/31 14:07:35
大佬看下
【冒泡】名字被和谐了 2018/7/31 14:08:06
为什么我输出的只有最后一个文件夹的文件
你撤回了一条消息
【冒泡】名字被和谐了 2018/7/31 14:09:08
【冒泡】名字被和谐了 2018/7/31 14:09:23

