java, writing data into notepad file using FileWriter, BufferedWriter

The below program is a very simple java code which uses File Writer and Buffered Writer to write data into notepad file, save and close

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

public class txt_write
{
    public static void main(String[] args) throws Exception
    {
     FileWriter fr=new FileWriter("e:\\sel-online\\data.txt");
     BufferedWriter br=new BufferedWriter(fr);
     br.write("This is sample data");
     br.newLine();
     br.write("selenium testing");
     br.newLine();
     br.write("java programming");
     br.newLine();
   
     br.close();
    }
}

Refer : www.venkatgnselenium.blogspot.in
 

Comments