1 | package de.ugoe.cs.eventbench.commands;
|
---|
2 |
|
---|
3 | import java.io.FileInputStream;
|
---|
4 | import java.io.IOException;
|
---|
5 | import java.io.ObjectInputStream;
|
---|
6 | import java.security.InvalidParameterException;
|
---|
7 | import java.util.List;
|
---|
8 |
|
---|
9 | import de.ugoe.cs.eventbench.data.GlobalDataContainer;
|
---|
10 | import de.ugoe.cs.util.console.Command;
|
---|
11 | import de.ugoe.cs.util.console.Console;
|
---|
12 |
|
---|
13 | /**
|
---|
14 | * <p>
|
---|
15 | * Command that loads a previously serialized {@link GlobalDataContainer}.
|
---|
16 | * </p>
|
---|
17 | *
|
---|
18 | * @author Steffen Herbold
|
---|
19 | * @version 1.0
|
---|
20 | */
|
---|
21 | public class CMDload implements Command {
|
---|
22 |
|
---|
23 | /*
|
---|
24 | * (non-Javadoc)
|
---|
25 | *
|
---|
26 | * @see de.ugoe.cs.util.console.Command#run(java.util.List)
|
---|
27 | */
|
---|
28 | @Override
|
---|
29 | public void run(List<Object> parameters) {
|
---|
30 | String filename;
|
---|
31 | try {
|
---|
32 | filename = (String) parameters.get(0);
|
---|
33 | } catch (Exception e) {
|
---|
34 | throw new InvalidParameterException();
|
---|
35 | }
|
---|
36 |
|
---|
37 | FileInputStream fis = null;
|
---|
38 | ObjectInputStream in = null;
|
---|
39 | try {
|
---|
40 | fis = new FileInputStream(filename);
|
---|
41 | in = new ObjectInputStream(fis);
|
---|
42 | in.readObject();
|
---|
43 | in.close();
|
---|
44 | } catch (IOException ex) {
|
---|
45 | Console.logException(ex);
|
---|
46 | } catch (ClassNotFoundException ex) {
|
---|
47 | Console.logException(ex);
|
---|
48 | }
|
---|
49 | }
|
---|
50 |
|
---|
51 | /*
|
---|
52 | * (non-Javadoc)
|
---|
53 | *
|
---|
54 | * @see de.ugoe.cs.util.console.Command#help()
|
---|
55 | */
|
---|
56 | @Override
|
---|
57 | public void help() {
|
---|
58 | Console.println("Usage: loadObject <filename>");
|
---|
59 | }
|
---|
60 |
|
---|
61 | }
|
---|