permaculture playing cards*
The moose likes Beginning Java and the fly likes SuppressedException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

SuppressedException

meeta gaur
Ranch Hand

Joined: Dec 05, 2012
Posts: 305



Have you any idea how to generate an exception in above resources statement ?

Thanks


My one regret in life is that I am not someone else.
- Woody Allen
Waldemar Macijewski
Ranch Hand

Joined: Jun 22, 2012
Posts: 32
Hi

You do not generate any exceptions, by using try and catch keywords you monitor piece of code which may create an exception and by using catch, you can "catch" this exception and handle it in some appropriate way. If you are referring to try with resources statement, then in try clause you declare and initialize objects whose resources are automatically managed. For example, if you create an instance of FileOutputStream, then any resources which are associated with this object (such as files in this case, but there also may be other resources such as network sockets, etc) are automatically closed. There is no need to call close() method in finally block.

for example:



meeta gaur
Ranch Hand

Joined: Dec 05, 2012
Posts: 305

I want to generate an exception in resources statement to check for suppressed exception.
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2332
    
  50
Please don't start new threads to ask questions related to the same problem. All further discussion should be directed to http://www.coderanch.com/t/601799/java/java/Throwable-getSupprssed

I'm locking this thread.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SuppressedException