BufferedWriter: write(String str) : BufferedWriter « java.io « Java by API






BufferedWriter: write(String str)

 
/*
 * Output:
 */

import java.io.BufferedWriter;
import java.io.FileWriter;

public class MainClass {

  public static void main(String args[]) {
    try {
      FileWriter fw = new FileWriter(args[0]);

      BufferedWriter bw = new BufferedWriter(fw);

      for(int i = 0; i < 12; i++) {
        bw.write("Line " + i + "\n");
      }

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








Related examples in the same category

1.new BufferedWriter(Writer out)
2.BufferedWriter: close()
3.BufferedWriter: flush()
4.BufferedWriter: write(String s, int off, int len)