Java: throws IOException

Status
Not open for further replies.

Nimdok

Ars Scholae Palatinae
1,214
Throw an IOException when an unexpected IO error may occur when calling a method.

When no error can occur or you've reached a point where it might be good to trap the error, you should no longer throw it.

An example of how it might be used:

Code:
public void writeData(File f) throws IOException {
  //you perform all sorts of actions here with IO and an error may occur
}

public void save() {
  try {
    writeData(theFile);
  }
  catch(IOException e) {
    //place exception message in error dialog or something similar
  }
}

You're asking a pretty vague question though. Perhaps you could post some code or more details?
 
Status
Not open for further replies.