Back to feed
Renewal·서른의 생활코딩

ex11) java.io.*

NS
normalstory
cover image

/*

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() );
}
}
}

This English version was translated by Codex.

친절한 찰쓰씨
Written by
친절한 찰쓰씨

Pleasant Charles — UI/UX researcher at AIT. Keeping notes on design, planning, and slow days here since 2010.

More on the author's page

Keep reading

Renewal

Steadily, for the long haul, without burning out

Mar 31, 2026·9 min
Renewal

Tech-life balance

Feb 7, 2026·3 min
Renewal

Humanality, by Park Jeong-ryeol

Feb 7, 2026·11 min