« Home | Program to Rename Files in a given Directory » 

Sunday, March 05, 2006 

Program to Write to a file

/* * FileOutputDemo * Using PrintStream classes * */

/* This program writes a given string to file named output.txt */
import java.io.*;
class FileOutputDemo
{
public static void main(String args[])
{
String a = "phanindra";
try {
FileOutputStream out = new FileOutputStream("output.txt");
PrintStream p = new PrintStream( out );
p.println (a);
p.close();
}
catch (Exception e) {
System.err.println ("Error writing to file");
}
}
}

About me

  • I'm phanindra
  • From Hyderabad, Andhra Pradesh, India
  • An Alumini of JNTU Hyd into happening IT industry...
My profile

Visitors
Bloggeries Blog Directory BlogRankings.com singapore blog directory blog search directory
Google
 
Web conceptoftheday.blospot.com