Try-with-resources: Must I throw or catch the close() method’s exceptions? [duplicate]

Quote from Java Language Specification ($14.20.3.2):

14.20.3.2 Extended try-with-resources

A try-with-resources statement with at least one catch clause and/or a finally
clause is called an extended try-with-resources statement.
The meaning of an extended try-with-resources statement:

    try ResourceSpecification
        Block
    Catchesopt
    Finallyopt

is given by the following translation to a basic try-with-resources statement
(§14.20.3.1) nested inside a try-catch or try-finally or try-catch-finally
statement:

    try {
        try ResourceSpecification
            Block
    }
    Catchesopt
    Finallyopt

The effect of the translation is to put the ResourceSpecification “inside” the try
statement. This allows a catch clause of an extended try-with-resources statement
to catch an exception due to the automatic initialization or closing of any resource.

So, basically, wrapper is already implemented

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)