Home Java Java-write Java write to stream
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Java write to stream

Advertisement
Following example demonstrates, how to write data in to the stream. In the example subclass CharArrayWriter of abstract Writer class is used to write data in to the underlying character stream.

Java write to stream

     

Following example demonstrates, how to write data in to the stream. In the example subclass CharArrayWriter of  abstract Writer class is used to write data in to the underlying character stream. In the example to write, data class methods are used. With  flush() method the data on the stream is flowed.

 

 

 

 

 

 

write_to_stream .java

import java.io.*;

public class write_to_stream {
  public static void main(String args[]) throws IOException {

  CharArrayWriter ch = new CharArrayWriter();
  CharSequence csq = "This stream is character output stream ";
  ch.append(csq);
  ch.flush();
  System.out.println(ch.toString());

  ch.write("and it is flowing inside\troseindia.net platform");
  ch.flush();
  System.out.println(ch.toString());

  }
}


Download the code

Advertisements

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: December 12, 2008

Ask Questions?    Discuss: Java write to stream   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com