import java.io.*; import java.io.FileReader; import java.io.BufferedReader; import java.io.PrintWriter; public class ww { public static void main(String[] args)throws FileNotFoundException, UnsupportedEncodingException, IOException { BufferedReader input; String title; File intermediate = new File("myfile1.txt"); PrintWriter output = new PrintWriter(intermediate, "UTF-8"); String p = "hh"; File dir = new File(p); File[] files = dir.listFiles(); for (File f : files) { if (f.isFile()) { input = new BufferedReader(new FileReader(f)); title = String.format("[%s\n_DATE]", f.getName()); output.println(title); System.out.println(title); while ((title = input.readLine()) != null) { output.println(title); System.out.println(title); } input.close(); } } output.close(); input = new BufferedReader(new FileReader(intermediate)); int count = 0; output = null; while ((title = input.readLine()) != null) { if (title.startsWith("[")) { if (output != null) output.close(); int index =title.indexOf ("."); title= title.substring (0, index); title = title.replace("["," "); output = new PrintWriter(new File(title +".txt" ), "UTF-8"); output.print("["); output.print(title); count++; continue; } output.println(title); } input.close(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)