Last change
on this file since 130 was
89,
checked in by sherbold, 13 years ago
|
|
-
Property svn:mime-type set to
text/plain
|
File size:
1.3 KB
|
Line | |
---|
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 | public class CMDloadObject implements Command {
|
---|
14 |
|
---|
15 | @Override
|
---|
16 | public void run(List<Object> parameters) {
|
---|
17 | String filename;
|
---|
18 | String objectName;
|
---|
19 | try {
|
---|
20 | filename = (String) parameters.get(0);
|
---|
21 | objectName = (String) parameters.get(1);
|
---|
22 | } catch (Exception e) {
|
---|
23 | throw new InvalidParameterException();
|
---|
24 | }
|
---|
25 |
|
---|
26 | Object data = null;
|
---|
27 | FileInputStream fis = null;
|
---|
28 | ObjectInputStream in = null;
|
---|
29 | try {
|
---|
30 | fis = new FileInputStream(filename);
|
---|
31 | in = new ObjectInputStream(fis);
|
---|
32 | data = in.readObject();
|
---|
33 | in.close();
|
---|
34 | } catch (IOException ex) {
|
---|
35 | ex.printStackTrace();
|
---|
36 | } catch (ClassNotFoundException ex) {
|
---|
37 | ex.printStackTrace();
|
---|
38 | }
|
---|
39 | if( GlobalDataContainer.getInstance().addData(objectName, data ) ) {
|
---|
40 | Console.traceln("Old data \"" + objectName + "\" overwritten");
|
---|
41 | }
|
---|
42 | }
|
---|
43 |
|
---|
44 | @Override
|
---|
45 | public void help() {
|
---|
46 | Console.println("Usage: loadObject <filename> <objectName>");
|
---|
47 | }
|
---|
48 |
|
---|
49 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.