Gestion des exceptions pour louverture de fichier
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.EOFException;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -32,8 +34,12 @@ public class Grid {
|
||||
}
|
||||
System.out.println("Success");
|
||||
System.out.println(this);
|
||||
} catch (FileNotFoundException e) {
|
||||
System.err.println("Erreur : Fichier non trouvé: " + e.getMessage());
|
||||
} catch (EOFException e) {
|
||||
System.err.println("Erreur : Fin de fichier atteinte prématurément: " + e.getMessage());
|
||||
} catch (IOException e) {
|
||||
System.err.println("Error: " + e.getMessage());
|
||||
System.err.println("Erreur d'entrée/sortie: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,8 +54,10 @@ public class Grid {
|
||||
output.writeInt(Integer.parseInt(line.toString()));
|
||||
}
|
||||
System.out.println("Grille sauvegardée avec succès dans " + fileName);
|
||||
} catch (FileNotFoundException e) {
|
||||
System.err.println("Erreur : Fichier non trouvé: " + e.getMessage());
|
||||
} catch (IOException e) {
|
||||
System.err.println("Erreur lors de la sauvegarde de la grille: " + e.getMessage());
|
||||
System.err.println("Erreur d'entrée/sortie: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user