[Java] Scanner VS BufferedReader

jipyo park·2022년 6월 7일
0

java

목록 보기
3/5
//Scanner 사용
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    }
}
// BufferedReader 사용
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) throws IOException {
    	BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    }
}

Parsing

Scanner는 Stream에서 정규표현식을 통해 구문분석을 하여 parsing.
BufferedReader는 just Reading.

Buffer 크기

Scanner Buffer Size : 1KB
BefferedReader Buffer Size : 8KB

동기화

Scanner : 단일 쓰레드
BufferedReader : 다중 쓰레드

BufferedReader는 Single Thread를 사용하는 Scanner보다 느리다
하지만 Parsing을 해주는 것 때문에 Scanner가 조금 더 느리게 작동

참고

6개의 댓글

comment-user-thumbnail
2022년 9월 18일

Well to know about the programming help here would be wise. The beginners who really want to fix the problem with they able to grab on https://www.mepits.com/product/2190/diy-kits/simple-diy-project-heartbeat-sensor here. Thumbs up with your further information online about programming that is recommending.

답글 달기
comment-user-thumbnail
2023년 8월 1일

The updates from the development side are pretty useful and helping for beginners. There should be people who might look for coding problem solutions can avail of supplement manufacturers information online. Continue with your tremendous work hope that is beneficial.

답글 달기
comment-user-thumbnail
2023년 8월 2일

An embryologist is a specialized scientist who handles the eggs, and embryos in the laboratory. They are responsible for fertilizing IVF Kosten of eggs, monitoring embryo development, and selecting the healthiest embryos for transfer.

답글 달기
comment-user-thumbnail
2023년 8월 10일

To truly harness the potential of AI in video editing, a holistic approach is crucial. Editors must understand the technical aspects of ai video generator algorithms while maintaining a clear artistic vision. By embracing AI as a tool rather than a replacement.

답글 달기
comment-user-thumbnail
2023년 10월 6일

The world is changing at an unprecedented pace. New technologies, industries, and ways of working emerge regularly. Lifelong learning equips individuals with the best essay writing service for college students tools they need to adapt to these changes, fostering resilience and the ability to thrive in uncertain environments.

답글 달기
comment-user-thumbnail
2024년 1월 6일

Celebrities extends far beyond red carpets and screens a significant number of stars have embraced a profound responsibility their biographyofacelebrity role in driving positive change through philanthropy.

답글 달기