inblog logo
|
harimmon
    자바

    [Java] 72. InputStreamReader

    백하림's avatar
    백하림
    Feb 19, 2025
    [Java] 72. InputStreamReader
    package ex18; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Buff02 { public static void main(String[] args) { InputStream in = System.in; InputStreamReader rd = new InputStreamReader(in); char[] buf = new char[4]; //길이가 4인 char[] buf 배열을 선언 try { //rd.read(buf)로 4글자를 읽어 배열에 저장한다. //입력이 4글자 미만이면 남은 배열 요소는 기본값 null로 채워진다. rd.read(buf); System.out.println(buf[0]); System.out.println(buf[1]); System.out.println(buf[2]); System.out.println(buf[3]); } catch (IOException e) { throw new RuntimeException(e); } } }
    notion image
    notion image
    Share article

    harimmon

    RSS·Powered by Inblog