±Û¾´ÀÌ :À±°æ±¸ 1998³â 1¿ù 17ÀÏ 09:00:11
In Reply to: System.in.read() IOException ¿¡·¯... posted by ¹Ú¼Ò¾Æ on 1998³â 1¿ù 16ÀÏ 11:18:07:
Àú´Â Àß µÇ´Âµ¥ ÀÌ»óÇϱº¿ä.
System.in.read()´Â ¹ÙÀÌÆ®¸¦ int °ªÀ¸·Î µÇµ¹¸³´Ï´Ù.
Äֿܼ¡¼ ÀÔ·ÂÇϸé ÄܼÖÀÌ ¹öÆÛ¸µÇϰí ÀÖ´Ù°¡ °³Ç๮ÀÚ°¡ µé¾î°¡¸é
System.inÀ¸·Î Àü´ÞµË´Ï´Ù.
import java.io.*;
public class test {
public static void main(String args[]){
int b=-1;
try {
do {
b = System.in.read();
System.out.println("READ:"+b);
} while (b != -1);
} catch (IOException ie) {
System.err.println("Exception:"+ ie.toString());
}
}
}
¸¸¾à Äֿܼ¡ ÀԷµǴ ¹®ÀÚ¿À» ÀÐ°í ½Í´Ù¸é ´ÙÀ½°ú °°ÀÌ º¯°æÇÒ ¼ö ÀÖ½À´Ï´Ù.
try {
BufferedReader is=new BufferedReader(new InputStreamReader(System.in));
String str=null;
do {
str = is.readLine();
System.out.println("READ:"+str);
} while (str != null);
} catch (IOException ie) {
System.err.println("EXCEPTION:"+ie.toString());
}