Top "Autocloseable" questions

java.

Close multiple resources with AutoCloseable (try-with-resources)

I know that the resource you pass with a try, will be closed automatically if the resource has AutoCloseable implemented. …

java sockets datainputstream try-with-resources autocloseable
What does idempotent method mean and what are the side effects in case of calling close method of java.lang.AutoCloseable?

Java docs of close() method of java.lang.AutoCloseable says Note that unlike the close() method of Closeable, this close() …

java idempotent autocloseable
Why is try-with-resources catch block selectively optional?

I read that the catch block in try-with-resources is optional. I've tried creating a Connection object in a try-with-resources block, …

java try-with-resources autocloseable
Try with multiple Resource in Java

I am new in Java8, and I want to know if, for the AutoCloseable resource, I have to add a …

java try-with-resources autocloseable
Right way to close CloseableHttpResponse/CloseableHttpClient

I'm using CloseableHttpResponse (from apache-httpclient-4.5.3) and I'm not sure I'm using it right, I saw an answer with no votes …

java apache-httpclient-4.x resource-cleanup autocloseable
Try-With Resource when AutoCloseable is null

How does the try-with feature work for AutoCloseable variables that have been declared null? I assumed this would lead to …

java try-catch autocloseable
Eclipse inconsistencies: Resource leak: '<unassigned Closeable value>' is never closed

If I have the following code: public OutputStream test(boolean condition) throws FileNotFoundException { return condition ? null : new FileOutputStream("test.txt"); } …

java eclipse autocloseable