• Post Reply Bookmark Topic Watch Topic
  • New Topic

FileWriter throwing an exception in my actionListener method

 
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: 2700
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need a try/catch statement:

 
Campbell Ritchie
Marshal
Posts: 52581
119
  • 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!