Code sample below converts inputstream to outputstream.
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();
}
}