How to Write to a file in Java كيفية الكتابة ف ملف نصى بالجافا

Posted: August 3, 2011 in Java SE

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package files;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
*
* @author Ahmed Abd El-Rasoul
*/
public class RwritetoFile2 {

public static void main(String [] args){

// Select the name of file using
File f=new File("ahmedd.txt");
try {
FileWriter fw = new FileWriter(f);
BufferedWriter bw=new BufferedWriter(fw);

bw.write("Ahmeeeeeeeed");
bw.flush();
System.out.println("String added");

} catch (IOException ex) {
Logger.getLogger(RwritetoFile2.class.getName()).log(Level.SEVERE, null, ex);
}

}

}

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s