Results 1 to 2 of 2
-
Converting InputStream to OutputStream
Code sample below converts inputstream to outputstream.
Java 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(); } }
- 01-11-2008, 10:13 PM #2
Member
- Join Date
- Jan 2008
- Posts
- 24
- Rep Power
- 0
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..
Similar Threads
-
Converting URL to URI
By Java Tip in forum Java TipReplies: 0Last Post: 12-26-2007, 10:15 AM -
Reading form inputStream and storing in ByteArray
By Java Tip in forum Java TipReplies: 0Last Post: 11-27-2007, 10:23 AM -
Reading bytes from InputStream
By Java Tip in forum Java TipReplies: 0Last Post: 11-25-2007, 07:51 PM -
Un expected behaviour when reading from inputstream
By adoorsarath in forum Advanced JavaReplies: 3Last Post: 08-10-2007, 05:02 PM -
HashMap to share OutputStream
By gabriel in forum Advanced JavaReplies: 1Last Post: 08-06-2007, 05:47 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks