Старался все соблюсти, но не проходит
package com.javarush.task.task31.task3101;
import java.io.*;
import java.util.*;
/*
Проход по дереву файлов
*/
public class Solution {
public static void main(String[] args) throws IOException {
List<String> name = new ArrayList<>();
// File path = new File("/home/dima/dsd3");
// File path1 = new File("/home/dima/dsd2");
File fileAll;
File path = new File(args[0]);
File resultFileAbsolutePath = new File(args[1]);
if(FileUtils.isExist(resultFileAbsolutePath)){
FileUtils.renameFile(resultFileAbsolutePath, new File("allFilesContent"));
}
Queue<File> queue = new LinkedList<>();
queue.add(path);
while (!queue.isEmpty()) {
fileAll = queue.poll();
for (File f : fileAll.listFiles()) {
if (f.isFile() && f.length() < 50) {
name.add(f.getName());
}
else if(f.isDirectory()) {
queue.add(f);
}
}
}
Collections.sort(name);
FileReader bufferedReader = null;
FileWriter bufferedWriter = new FileWriter(resultFileAbsolutePath, true);
for (String n: name) {
bufferedReader = new FileReader (path +"/"+ n);
Scanner sc = new Scanner(bufferedReader);
while (sc.hasNext()) {
bufferedWriter.write(sc.nextLine());
}
bufferedWriter.write("\n");
sc.close();
}
bufferedReader.close();
bufferedWriter.close();
}
}