새로워지기/서른의 생활코딩
ex6) java.io.*
청춘만화
2012. 3. 6. 00:11
import java.io.*;
public class InputStreamReaderTest2 {
public static void main( String[] args ) {
// byte Stream인 is 선언
InputStream is = System.in;
// InputStreamReader 객체 선언
InputStreamReader isr = new InputStreamReader( is );
int inputValue = 0;
char[] temp = new char[10];
System.out.print( "Input Value : " );
try {
// 키보드로 부터 데이타를 입력
inputValue = isr.read( temp );
} catch ( IOException io ) {
}
System.out.println( "InputValue : " + inputValue );
// char[]의 값을 출력
for( int i=0 ; i<inputValue ; i++ ) {
System.out.println( temp[i] );
}
// char[]을 String type으로 변환
System.out.println( "char[] -> String : " + new String( temp ));
}
}