Подскажите, куда копать?
package com.javarush.task.task31.task3101;
import java.io.*;
import java.util.*;
/*
Проход по дереву файлов
*/
public class Solution {
public static void main(String[] args) {
ArrayList<File> arLst = new ArrayList<>();
File folder = new File(args[0]);
fold(folder, arLst);
TreeMap<String, File> tM = new TreeMap<>();
for (File st : arLst) {
tM.put(st.getName(), st);
}
try {
File result = new File(args[1]);
if (!result.exists()) {
result.createNewFile();
}
File newResult = new File(result.getParent() + "/allFilesContent.txt");
if (newResult.exists()) {
newResult.delete();
}
FileUtils.renameFile(result, newResult);
FileOutputStream os = new FileOutputStream(newResult);
for (Map.Entry<String, File> entry : tM.entrySet()) {
System.out.println(entry.getKey());
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(entry.getValue())));
String s;
while ((s = br.readLine()) != null) {
os.write((s + "\n").getBytes());
os.write(System.lineSeparator().getBytes());
}
br.close();
}
os.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void fold(File fl, ArrayList<File> aL) {
for (File file : fl.listFiles()) {
if (file.isFile()) {
if (file.length() < 50) {
aL.add(file);
}
}
if (file.isDirectory()) {
fold(file, aL);
}
}
}
}