-5
我有一個循環,發現在一個目錄下的所有文件,我想要做的就是添加一行代碼到它會寫這些結果成txt文件,如何將我最好做到這一點
當前代碼:
public String FilesInFolder() {
// Will list all files in the directory, want to create a feature on the page that can display this to the user
String path = NewDestination;
System.out.println("Starting searching files in directory"); // making sure it is called
String files;
File folder = new File(path);
File[] listOfFiles = folder.listFiles();
for (int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].isFile()) {
files = listOfFiles[i].getName();
System.out.println(files);
}
}
return "";
}
使用BufferWriter? – PermGenError 2013-02-08 18:14:08
http://docs.oracle.com/javase/tutorial/essential/io/file.html – 2013-02-08 18:15:06