Gestion des exceptions pour louverture de fichier

This commit is contained in:
2024-05-04 16:54:22 +02:00
parent f5d9276a33
commit 2ab5388dc1
11 changed files with 12 additions and 4 deletions
+10 -2
View File
@@ -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());
}
}
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
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.