Java BufferedReader copy to BufferedWriter

Description

Java BufferedReader copy to BufferedWriter


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class Main {
   public static void main(String args[]) throws IOException {
      BufferedReader in = new BufferedReader(new FileReader(args[0]));
      BufferedWriter out = new BufferedWriter(new FileWriter(args[1]));
      String line;//  w  w w .j a  v  a2  s .c  o m
      while ((line = in.readLine()) != null) {
         out.write(line, 0, line.length());
         out.newLine();
      }
      in.close();
      out.close();
   }
}



PreviousNext

Related