According to my knowledge, we use try catch as follows:
try { //Some code that may generate exception } catch(Exception ex) { } //handle exception finally { //close any open resources etc. }
But in the code I found after
try( ByteArrayOutputStream byteArrayStreamResponse = new ByteArrayOutputStream(); HSLFSlideShow pptSlideShow = new HSLFSlideShow( new HSLFSlideShowImpl( Thread.currentThread().getContextClassLoader() .getResourceAsStream(Constants.PPT_TEMPLATE_FILE_NAME) )); ){ } catch (Exception ex) {
I cannot understand why these are parentheses () right after the attempt.
What is its use? Is this new in Java 1.7? What syntax can I write there?
Please also call me some API docs.
source share