---
title: "Discussion on \"try-with-resources란?\" | Hashnode"
description: "Discussion on \"try-with-resources란?\". Java에서는 파일, 소켓, DB커넥션 등 외부 자원을 사용할 경우 반드시 사용 후 자원을 닫아줘야 합니다.\n그렇지 않으면 메모리 누수, 파일 잠금, 성능 저하 등의 문제가 발생할 수 있습니다.\n이를 안전하고 간결하게 처리할 수 있도록 Java 7부터 도입된 문법이 바로 try-with-resources 입니다.\n\n기존 방식의 한계\n그동안은 아래처럼 try-catch-finally 구문을 사용해 닫는 방식이 일반적이었습니다.\nBufferedRe..."
url: "https://hashnode.com/posts/try-with-resources/6892ea87f12f723997db4e03"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [try-with-resources란?](https://gaeng.hashnode.dev/try-with-resources?utm_source=hashnode&utm_medium=feed)

Java에서는 파일, 소켓, DB커넥션 등 외부 자원을 사용할 경우 반드시 사용 후 자원을 닫아줘야 합니다. 그렇지 않으면 메모리 누수, 파일 잠금, 성능 저하 등의 문제가 발생할 수 있습니다. 이를 안전하고 간결하게 처리할 수 있도록 Java 7부터 도입된 문법이 바로 try-with-resources 입니다. 기존 방식의 한계 그동안은 아래처럼 try-catch-finally 구문을 사용해 닫는 방식이 일반적이었습니다. BufferedRe...

Aug 6, 2025 · 2 min read · gaeng.hashnode.dev  
Read the article

-   [#java](https://hashnode.com/tag/java)
-   [#try-with-resources](https://hashnode.com/tag/try-with-resources)

## Written by

[갱갱](https://hashnode.com/@minkyeong)

@minkyeong

  
[View profile](https://hashnode.com/@minkyeong)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
