metti il codice tra
try {
codice
}
catch (IOException ex) {}