new FileWriter(String string) : FileWriter « java.io « Java by API






new FileWriter(String string)

  
/*
 * Output:
 *  
 */

import java.io.FileReader;
import java.io.FileWriter;

//copy file
public class MainClass {

  public static void main(String args[]) {

    try {

      FileReader fr = new FileReader(args[0]);

      FileWriter fw = new FileWriter(args[1]);

      int i;
      while ((i = fr.read()) != -1) {
        fw.write(i);
      }
      fw.close();

      fr.close();
    } catch (Exception e) {
      System.out.println("Exception: " + e);
    }
  }
}        
         
    
  








Related examples in the same category

1.new FileWriter('LPT1:')
2.new FileWriter(File file)
3.new FileWriter(String fileName, boolean append)
4.FileWriter: close()
5.FileWriter: flush()
6.FileWriter: write(int i)