The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
January 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

how to write to file

Posted by elmahadi ebrahim on July 24, 2001 at 4:42 AM

> > > Use BufferedWriter and BufferedReader to write and read the file. It will use text only. No junk at all!!!

> > Hi,

> > Perhaps this illustration code to help you on your way?

> > import java.io.*;

> > class SaveLabel
> > {
> > public static void main( String args[] )
> > throws IOException
> > {
> > PrintWriter fout = new PrintWriter( new FileWriter( "label.out" ) );

> > System.out.println( "Printing the label to 'label.out'" );

> > fout.println( "------------------------" );
> > fout.println( "| |" );
> > fout.println( "| |" );
> > fout.println( "| Geert Vancompernolle |" );
> > fout.println( "| |" );
> > fout.println( "| |" );
> > fout.println( "------------------------" );
> > fout.close();
> > System.out.println( "Program finished" );
> > }
> > }

> >
> > HTH,

> > Rgds,

> > Geert





Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us