Create BufferedWriter from FileWriter - Java File Path IO

Java examples for File Path IO:FileWriter

Description

Create BufferedWriter from FileWriter

Demo Code



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

public class testfilecreation {
public static void main(String[] args) {
  try/*from w  w w.j a  v a  2  s  . c om*/
  {
    FileWriter fstream = new FileWriter("d:\\out.txt");
  
    BufferedWriter bufferedWriter = new BufferedWriter(fstream);
    bufferedWriter.write("Hello Java");
    //Close the output stream
    bufferedWriter.close();
  }catch (Exception e){//Catch exception if any
    System.err.println("Error: " + e.getMessage());
  }
}
}

Related Tutorials