This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

FileWriter throwing an exception in my actionListener method  RSS feed

 
Patrick Morris
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Trying to write my question and answering array to a file but it keeps telling me about an unreported IO exception might be thrown. I attempted to put a throws expection in the public void action performed method but it throws another error message. I'll post the code, the error message will be the last lines in the code below:










[
 
Rob Camick
Ranch Hand
Posts: 2752
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need a try/catch statement:

 
Campbell Ritchie
Sheriff
Posts: 53734
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe better with a try‑with‑resources (not available in Java6). You can read why you must use a try in the Java┬« Tutorials.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!