1
이 문자열을 파일 목록과 함께 파일에 저장하려하지만 마지막 하나만 저장합니다. 여기에있는 문제는 무엇입니까? :(파일 목록을 .txt로 저장합니다.
public void fileprinter() throws IOException{
File dir = new File("c:");
String[] children = dir.list();
if (children == null) {
} else {
for (int i=0; i<children.length; i++) {
String filename = new StringBuffer().append(children[i]).toString();
System.out.println(filename);
Writer output;
File file = new File("D:/file.txt");
output = new BufferedWriter(new FileWriter(file));
output.write(filename);
output.close();
}
}
}