Writing to a text file – using Writer – simple example

import java.io.*;

public class 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 + "\n");
System.out.println("Your file has been written");



Leave a comment

Filed under Java

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s