Подскажите, что может быть не так.
package com.javarush.task.task31.task3101;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.*;
import java.util.stream.Collectors;
/*
Проход по дереву файлов
*/
public class Solution {
public static void main(String[] args) throws IOException {
String path = args[0];
String resultFileAbsolutePath = args[1];
File resultFile = new File(resultFileAbsolutePath);
File dest = new File(resultFile.getParentFile() + "/allFilesContent.txt");
if (FileUtils.isExist(dest)) {
FileUtils.deleteFile(dest);
}
FileUtils.renameFile(resultFile, dest);
Map<String, String> resultFileNames = new TreeMap<>();
getFilesFromParent(new File(path), resultFileNames);
try (FileWriter fileWriter = new FileWriter(dest)) {
fileWriter.write(String.join("\n", resultFileNames.values()));
}
}
private static void getFilesFromParent(File parent, Map<String, String> resultFileNames) throws IOException {
List<File> childs = Arrays.asList(parent.listFiles());
for (File childFile : childs) {
if (childFile.isFile() && childFile.length() <= 50) {
resultFileNames.put(childFile.getName(), new String(Files.readAllBytes(childFile.toPath())));
} else if (childFile.isDirectory()) {
getFilesFromParent(childFile, resultFileNames);
}
}
}
}