Created
December 18, 2019 08:43
-
-
Save Tim719/a87cd196fdadb932e41419ac3da93b03 to your computer and use it in GitHub Desktop.
LireMessage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
public class LireMessage { | |
public static void main(String[] args) { | |
if (args.length < 1) { | |
System.out.println("usage: java LireMessage <dest>"); | |
} | |
else { | |
try { | |
File src = new File(args[0]); | |
FileInputStream fin = new FileInputStream(src); | |
ObjectInputStream oin = new ObjectInputStream(fin); | |
Message m = (Message) oin.readObject(); | |
System.out.println("m = " + m); | |
oin.close(); | |
fin.close(); | |
} catch (FileNotFoundException e) { | |
System.err.println("ERR: Le fichier source n'existe pas ou le fichier de destination ne peut être crée ou ouvert."); | |
} catch (IOException e) { | |
System.err.println("ERR: entrée/sortie."); | |
} catch (ClassNotFoundException e) { | |
System.err.println("ERR: impossible de trouver la classe"); | |
} finally { | |
System.out.println("END"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment