Skip to content

Commit

Permalink
GITBOOK-127: No subject
Browse files Browse the repository at this point in the history
  • Loading branch information
GoldenPearls authored and gitbook-bot committed Sep 19, 2024
1 parent f6cd68f commit 38a1c6e
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ static void copy(String src, String dst) throws IOException {

λ˜ν•œ, `try-with-resources`μ—μ„œλ„ `catch` μ ˆμ„ μ‚¬μš©ν•  수 μžˆμ–΄ μ˜ˆμ™Έ 처리λ₯Ό μœ μ—°ν•˜κ²Œ ν•  수 μžˆλ‹€.

* **`try` 블둝**: 전체 μžμ› 관리와 μ˜ˆμ™Έ 처리λ₯Ό λ‹΄λ‹Ήν•˜λŠ” 블둝
* **`with` λΆ€λΆ„**: `try` λ’€μ˜ κ΄„ν˜Έ μ•ˆμ—μ„œ μžμ›μ„ μ„ μ–Έν•˜κ³  μ΄ˆκΈ°ν™”ν•˜λŠ” λΆ€λΆ„
* **`resources`**: `with` λΆ€λΆ„μ—μ„œ μ„ μ–Έλœ μžμ› κ°μ²΄λ“€λ‘œ, `AutoCloseable`을 κ΅¬ν˜„ν•΄μ•Ό ν•œλ‹€
* **with 블둝 (μžμ› μ„ μ–Έ λΆ€λΆ„)**:
* `InputStream in = new FileInputStream("input.txt");`
* `OutputStream out = new FileOutputStream("output.txt");`
* μ—¬λŸ¬ μžμ›μ„ μ„Έλ―Έμ½œλ‘  `;`으둜 κ΅¬λΆ„ν•˜μ—¬ μ„ μ–Έν•  수 μžˆλ‹€.
* **resource (μžμ›λ“€)**:
* `in`κ³Ό `out`이 각각의 μžμ›μ΄λ‹€.

#### μ½”λ“œ 9-5: `try-with-resources`에 `catch` μ ˆμ„ ν•¨κ»˜ μ‚¬μš©

```java
Expand Down

0 comments on commit 38a1c6e

Please sign in to comment.