Skip to content

Instantly share code, notes, and snippets.

@Tim719
Created December 18, 2019 08:43
Show Gist options
  • Save Tim719/a87cd196fdadb932e41419ac3da93b03 to your computer and use it in GitHub Desktop.
Save Tim719/a87cd196fdadb932e41419ac3da93b03 to your computer and use it in GitHub Desktop.
LireMessage
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