Code/JAVA

java IO

sidcode 2007. 10. 28. 16:53
/*
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
*/
import java.io.*;

public class io {
    public static void main(String[] test) throws IOException{        
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        
        // 캐릭터형
        System.out.print("a : ");
        char a = (char)System.in.read();
        
        // \r\n 등의 값 처리
        System.in.read();
        
        // 문자열
        System.out.print("b : ");
        String b = in.readLine();
        
        // 정수형
        System.out.print("c: ");
        String imsi = in.readLine();
        int c = Integer.parseInt(imsi);
         /*  라인줄이기
          System.out.print("c: ");
          int c = Integer.paserint(in.readLine());
          */

        /* 기타 값 받기 (라인줄이기 가능 위 "라인줄이기" 참고)
         * byte c = Byte.parseByte(imsi);
         * short c = Short.parseShort(imsi);
         * long c = Long.parseLong(imsi);
         * float c = Float.parseFloat(imsi);
         * double c = Double.parseDouble(imsi);
         * boolean ("라인줄이기" 비참고)
         * boolean c = Boolean.valueOf(imsi).booleanValue(); // 입력 가능값 false, true
         */
        
        System.out.println("a : " + a + " b : " + b + " c : " + c);        
    }
}

참고 하셔요.!!!