У меня не происходит запись в файл. Никак не пойму почему. Хелпаните плиз, я обязан решить эту задачу. Я что-то недопонимаю, объясните пожалуйста.
package com.javarush.task.task31.task3101;
import java.io.*;
import java.nio.file.Files;
import java.util.*;
import static java.lang.Integer.MAX_VALUE;
public class Solution {
public Map<String, String> map = new TreeMap<>();
private void recursFind(String path) {
File file = new File(path);
if (file.isDirectory()) {
File[] files = file.listFiles();
if (files != null) {
for (File f : files) {
recursFind(f.getPath());
}
}
} else {
if (file.length() <= 50) {
map.put(file.getName(), file.getParent());
}
}
}
public static void main(String[] args) throws IOException {
if (args.length > 0) {
File path = new File(args[0]);
File resultFileAbsolutePath = new File(args[1]);
File allFilesContent = new File(resultFileAbsolutePath.getParent() + "/allFilesContent.txt");
if (!(resultFileAbsolutePath.exists() && resultFileAbsolutePath.isFile())) {
resultFileAbsolutePath.renameTo(allFilesContent);
}
FileUtils.renameFile(resultFileAbsolutePath, allFilesContent);
Solution sol = new Solution();
sol.recursFind(path.toString());
BufferedReader br;
BufferedWriter bw = new BufferedWriter(new FileWriter(allFilesContent));
for (Map.Entry<String, String> f : sol.map.entrySet()) {
br = new BufferedReader(new FileReader(f.getValue() + "\\" + f.getKey()));
while (br.ready()) {
Character s = (char) br.read();
bw.write(s + "\n");
}
br.close();
}
bw.close();
}
}
}