Hirdetés

2024. május 4., szombat

Gyorskeresés

Útvonal

Fórumok  »  Szoftverfejlesztés  »  Java programozás (kiemelt téma)

Hozzászólások

(#12028) sztanozs válasza Ablakos (#12026) üzenetére


sztanozs
veterán

Remelem nem gond az angol:

Catch Block
You can add a catch block to a try-with-resources block just like you can to a standard try block. If an exception is thrown from within the try block of a try-with-resources block, the catch block will catch it, just like it would when used with a standard try construct.

Before the catch block is entered, the try-with-resources construct will attempt to close the resources opened inside the try block. In case an exception is thrown when attempting to close one of the resources, these exceptions will be available from the exception's getSuppressed() method inside the catch block. Here is an example of a Java try-with-resources block with a catch block attached:

try(AutoClosableResource resourceOne = new AutoClosableResource("One", true)) {
resourceOne.doOp(true);
} catch(Exception e) {
Throwable[] suppressed = e.getSuppressed();
throw e;
}

JOGI NYILATKOZAT: A bejegyzéseim és hozzászólásaim a személyes véleményemet tükrözik; ezek nem tekinthetők a munkáltatóm hivatalos állásfoglalásának...

Útvonal

Fórumok  »  Szoftverfejlesztés  »  Java programozás (kiemelt téma)
Copyright © 2000-2024 PROHARDVER Informatikai Kft.