Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-11-2008, 11:22 AM
Moderator
 
Join Date: Nov 2007
Posts: 1,657
Java Tip will become famous soon enoughJava Tip will become famous soon enough
Converting InputStream to OutputStream
Code sample below converts inputstream to outputstream.
Code:
import java.io.*; public class InputToOutputStream { public static void main( String args[] ) throws IOException { InputStream in = new FileInputStream ( "InputToOutputStream.java" ); OutputStream out = System.out; int nextChar; while ( ( nextChar = in.read() ) != -1 ) out.write( Character.toUpperCase( (char) nextChar ) ); out.write( '\n' ); out.flush(); } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-12-2008, 12:13 AM
Member
 
Join Date: Jan 2008
Posts: 24
afsina is on a distinguished road
Some corrections:

this class does not convert an inputstream to outputstream. what it does is writing a file's contents to the console as character by character and adding a new line after each character . Also this method works, but you should close streams in finally blocks, and you don't need to flush the output stream after each write operation..
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting URL to URI Java Tip Java Tips 0 12-26-2007 12:15 PM
Reading form inputStream and storing in ByteArray Java Tip Java Tips 0 11-27-2007 12:23 PM
Reading bytes from InputStream Java Tip Java Tips 0 11-25-2007 09:51 PM
Un expected behaviour when reading from inputstream adoorsarath Advanced Java 3 08-10-2007 07:02 PM
HashMap to share OutputStream gabriel Advanced Java 1 08-06-2007 07:47 PM


All times are GMT +3. The time now is 11:21 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org