← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #279759]: read and write

 

Question #279759 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/279759

Description changed to:
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();
  }
}

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.