package com.test.java;
import java.util.Scanner;
public class Ex28_Scanner {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
// 문자 입력
// System.out.print("입력: ");
// String line = scan.nextLine(); // reader.readLine() > \r\n 자동 소멸
// System.out.println(line);
// System.out.print("숫자: ");
// int num = scan.nextInt();
// System.out.println(num + 10);
// 자료형별로 입력받는 메서드 제공
// System.out.print("숫자: ");
// num = scan.nextInt(); // 입력 받은 걸 무조건 int 로
// System.out.println(num + 10);
// scan.nextLine(); // 편법, 남아있는 엔터를 지우는 역할
// scan.skip("\r\n"); // 연속으로 숫자를 받을 땐 괜찮음 숫자 입력 후 문자받을 때만 신경쓰기
// System.out.print("입력: ");
// line = scan.nextLine();
// System.out.println("마지막: " + line); // 입력도 안했는데 끝남, 숫자 입력 후 문자입력하면 스킵이 되어버림 \r\n 이 살아있어서...
System.out.print("입력: ");
// Finds and returns the next complete token from this scanner.
// 토큰 > 공백으로 구분되는 단어 (따로 얻을 때 사용)
// 단어 하나일때, next 와 nexLine 상관없이 쓰면 되지만, 공백 들어가면 고민
// String txt = scan.next();
// System.out.println(txt);
// txt = scan.next();
// System.out.println(txt);
// txt = scan.next();
// System.out.println(txt);
//TODO 다음에 다시 정리!!!
String txt = "";
while (scan.hasNext()) { // 이렇게만 쓰면 무한 루프됨
txt = scan.next();
System.out.println(txt);
// 읽어올게 아직 남았는지 안남았는지 판단해줌
}
System.out.println("종료");
}
}