This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Convert IOException to String? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Convert IOException to String?" Watch "Convert IOException to String?" New topic
Author

Convert IOException to String?

John Reese
Greenhorn

Joined: Apr 04, 2009
Posts: 7
Hi,
I don't understand what type the exception below is. I can print it out which makes me think of the exception as a string. However, if I try to save it to a string, I get the following compilation error:

How can I save this as a string?
Ralph Cook
Ranch Hand

Joined: May 29, 2005
Posts: 479
You could do
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 20078
    
  30

Or Both can be what you want depending on what you want to be in the String exactly. The String returned by toString() includes the exception's class name and the message, unless it's null. getMessage() only returns the message, and that can be null.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
 
Have you checked out Aspose?
 
subject: Convert IOException to String?
 
It's not a secret anymore!