/* * WriteTextFileExample.java * * Created on January 10, 2011, 5:07 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package file; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.Writer; /** * * @author ocamposm */ public class WriteTextFileExample { /** Creates a new instance of WriteTextFileExample */ public WriteTextFileExample() { } public static void main (String[] args) throws IOException { Writer output = null; String text ="Rajesh Kumar"; File file = new File("write.txt"); output = new BufferedWriter(new FileWriter(file)); output.write(text); output.close(); System.out.println("Your File has been written"); } }