/*
import java.io.*;
public class OutputStreamTest {
public static void main( String[] args ) {
// InputStream object that receives keyboard input
// and refers to that object
InputStream is = System.in; // keyboard device, byte-based input unit, no buffer allocation
// OutputStream reference variable for sending values to the standard output device
// referring to the output object
OutputStream out = System.out; // monitor, byte-based output unit, no buffer allocation
System.out.print( "Input Value : " );
try {
// receive a value from the standard input device
int input = is.read();
System.out.println( "inputValue = " + input ); // comes out garbled
System.out.println();
// output the value to the standard output device
System.out.print( "out.write = " );
out.write( input );
// close the stream and release the resource
out.close(); // close
} catch ( IOException io ) {
System.out.println( io.toString() );
}
}
}
**/
**/
import java.io.*;
public class OutputStreamWriterTest {
public static void main( String[] args ) {
// char[] that stores input data
char[] store = new char[10];
// InputStream object that receives keyboard input
// referring to the object
InputStream is = System.in;
// OutputStream reference variable for standard output
// referring to the output object
OutputStream out = System.out;
// receives a node stream as an argument
// converts byte-based data into character-based data
InputStreamReader isr = new InputStreamReader( is ); // read as chars
// receives a node stream as an argument
// converts character-based data back into byte-based data for output
OutputStreamWriter osw = new OutputStreamWriter( out );// output as chars
System.out.print( "Input Value : " );
try {
// store data up to the size of the array
int input = isr.read( store );
System.out.println( "Input Value Count = " + input );
// convert the array into a string
System.out.println( "String value = " + new String( store ));
System.out.println();
// output the array data to the standard output device
System.out.print( "OutputStreamWriter send value : " );
osw.write( store );
// release the stream and return the resource
osw.close();
} catch ( IOException io ) {
System.out.println( io.toString() );
}
}
}
