Tuesday, August 31, 2010

Article | Java - Write To File Example

Class FileWriter - The FileWriter is a class used for writing character files.

Class BufferedWriter - The BufferWriter class is used to write text to a character-output stream, buffering characters. It will help us to provide for the efficient writing of single characters, arrays, and strings.



  1. import java.io.*;

  2. class FileWrite

  3. {

  4. public static void main(String args[])

  5. {

  6. try{

  7. // Create file

  8. FileWriter fstream = new FileWriter("out.txt");

  9. BufferedWriter out = new BufferedWriter(fstream);

  10. out.write("Hello Java");

  11. //Close the output stream

  12. out.close();

  13. }catch (Exception e){//Catch exception if any

  14. System.err.println("Error: " + e.getMessage());

  15. }

  16. }

  17. }

Loading...

Comments :

0 comments to “ Java - Write To File Example ”

Top Views

BloggerTipsTemplates

CHICKLETS

Enter your email address:

Delivered by FeedBurner

Followers