--- id: java-bufferedreader title: "Java BufferedReader" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["μžλ°” BufferedReader"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.88 created_at: 2026-07-04 updated_at: 2026-07-04 review_reason: "" merge_history: [] tags: ["java", "programming", "w3schools", "io", "bufferedreader", "character-stream"] raw_sources: ["https://www.w3schools.com/java/java_bufferedreader.asp"] applied_in: [] github_commit: "" --- # [[Java BufferedReader]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) `BufferedReader` never opens files directly β€” it always wraps a `FileReader`, which handles the actual file-opening while BufferedReader adds a memory buffer on top to make line-by-line reading (`readLine()`) fast for large files, a decorator-pattern relationship rather than a standalone class. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **`BufferedReader`** β€” reads text line-by-line via `readLine()`; must be paired with `FileReader` (which opens the file). [S1] - **`readLine()`** β€” returns `null` at end-of-file, used as the loop termination condition. [S1] - **Buffer for speed** β€” the class uses an internal memory buffer to make reading faster than unbuffered access. [S1] - **Best use case** β€” large text files, since it's faster and uses less memory than Scanner. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Line-by-line read: `try (BufferedReader br = new BufferedReader(new FileReader("filename.txt"))) { String line; while ((line = br.readLine()) != null) { System.out.println(line); } } catch (IOException e) {...}`. [S1] - Class comparison: Scanner (simple text, split into lines/words/numbers), BufferedReader (large text files, faster, less memory, readLine()), FileInputStream (binary files). [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) μ†ŒμŠ€μ—μ„œ λͺ¨μˆœλ˜λŠ” μ •λ³΄λŠ” λ°œκ²¬λ˜μ§€ μ•ŠμŒ. ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” λŒ€μš©λŸ‰ ν…μŠ€νŠΈ νŒŒμΌμ„ λΉ λ₯΄κ²Œ ν•œ 쀄씩 μ½λŠ” ν‘œμ€€ νŒ¨ν„΄μ΄λ‹€. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Reading a file line by line with BufferedReader (Java): ```java try (BufferedReader br = new BufferedReader(new FileReader("filename.txt"))) { String line; while ((line = br.readLine()) != null) { System.out.println(line); } } catch (IOException e) { System.out.println("Error reading file."); } ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.88 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[Java Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[Java FileInputStream]], [[Java BufferedWriter]], [[Java Files Read]] - **μ°Έμ‘° λ§₯락:** 버퍼링을 ν†΅ν•œ λΉ λ₯Έ ν…μŠ€νŠΈ 읽기 β€” BufferedWriter와 λŒ€μΉ­λ˜λŠ” μ“°κΈ° 클래슀. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” Java BufferedReader β€” https://www.w3schools.com/java/java_bufferedreader.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "Java BufferedReader and BufferedWriter" page (Astra wiki-curation, P-Reinforce v3.1 format).