public static void main(String[] args) throws IOException {
FileWriter writer = new FileWriter(new File("D://result.txt"));
displayAll(new File("D:\\Archive"), writer);
writer.close();
}
public static void displayAll(File path, FileWriter writer) throws IOException {
if(path.isFile()){
writer.write(path.getAbsolutePath()+"\n");
}else{
writer.write(path.getAbsolutePath()+"\n");
File files[] = path.listFiles();
for(File dirOrFile: files){
displayAll(dirOrFile, writer);
}
}
}