문제
이름을 입력받아 인사말을 출력할 때 입출력 속도를 개선하는 문제입니다 이를 해결하는 프로그램의 다음 실행상태에 대해 빈칸을 채우세요
프로그램의 실행순서 및 실행상태
1 public static void main( String[] args )
4 new BufferedReader( new InputStreamReader( System.in ) );
E001 // 장치가 준비되지 않았습니다
| | main() | |
| br | | | (IOException객체) |
2 throws IOException {
E002 // IOException에서 예외 처리 후 프로그램 종료
Exception in thread 'main' java.io.IOException
at java.base/java.io.Reader.<init>(Reader.java 167)
at java.base/java.io.InputStreamReader.<init>(InputStreamReader.java 72)
at Main.main(Main.java 4)
프로그램 코드
E001 // 장치가 준비되지 않았습니다
E002 // IOException에서 예외 처리 후 프로그램 종료
import java.io.*;
public class InputOutputStreamException
{
1 public static void main( String[] args )
2 throws IOException {
3 BufferedReader br =
4 new BufferedReader( new InputStreamReader( System.in ) );
5 BufferedWriter bw =
6 new BufferedWriter( new OutputStreamWriter( System.out ) );
7 bw.write( "이름을 입력하세요: " );
8 bw.flush();
9 String name = br.readLine();
10 bw.write( "안녕하세요, " + name + "님. 만나서 반갑습니다" );
11 bw.flush();
bw.close();
12 br.close();
}
}