Quick Q
i have a loop that finds all the files in a directory, what i want to do is add a line of code into it that would write these results into a txt file, how would i best do this
current code :
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 "";
}
You can use FileWriter and StringWriter together.