aspose file tools*
The moose likes Beginning Java and the fly likes Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Exception" Watch "Exception" New topic
Author

Exception

Mauro Trevigno
Ranch Hand

Joined: Aug 27, 2012
Posts: 64

Hi guys,

Im catching the exception and I want to print a more specific exception, its this possible?

Because if i fo to java.lang.Exception, we have a lot of subclasses:
ex.
AclNotFoundException, ActivationException, AlreadyBoundException, ApplicationException, AWTException, BackingStoreException, BadLocationException, CertificateException.





Thanks.

Regards,
-M
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Im catching the exception and I want to print a more specific exception, its this possible?

Yes. If no exception class from the API suits your needs, you can make your own class by extending java.lang.Exception and throw an instance of it.


[My Blog]
All roads lead to JavaRanch
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61768
    
  67

Mauro Trevigno wrote:Im catching the exception and I want to print a more specific exception, its this possible?

It depends what you mean by that. Your print statement will print whatever the exception really is, regardless of what you catch it as.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception