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:

Re: Writing to a file

Posted by Geert Vancompernolle on January 10, 2001 at 3:28 PM

> InputStream is = (InputStream)o;
> int c;
> FileOutputStream fw = new FileOutputStream("sanu.txt");
> do {
> c = is.read();// is is an InputStream object
> if ( c != -1 )
> {
> fw.write( c );
> }
> } while( c != -1 );
> fw.close();

> But when I am opening sanu.txt I am getting junc character for newline character.It is not in the format as original.NewLine character are not coming.
> Please send me answer(codes) as soon as possible.

Hi,

Perhaps you can try the following code. It's just a quick way to help you, but it works...

import java.io.*;

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

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

fout.println( name );
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