Last change
on this file since 151 was
90,
checked in by sherbold, 14 years ago
|
- renamed getReplayXML to getReplay in de.ugoe.cs.eventbench.data.IReplayable and implementing classes
- minor changes
|
-
Property svn:mime-type set to
text/plain
|
File size:
1.2 KB
|
Line | |
---|
1 | package de.ugoe.cs.eventbench.commands;
|
---|
2 |
|
---|
3 | import java.io.FileOutputStream;
|
---|
4 | import java.io.IOException;
|
---|
5 | import java.io.ObjectOutputStream;
|
---|
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 CMDsaveObject 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 | }
|
---|
23 | catch (Exception e) {
|
---|
24 | throw new InvalidParameterException();
|
---|
25 | }
|
---|
26 |
|
---|
27 | Object dataObject = GlobalDataContainer.getInstance().getData(objectName);
|
---|
28 | if( dataObject==null ) {
|
---|
29 | Console.println("Object " + objectName + " not found in storage.");
|
---|
30 | }
|
---|
31 |
|
---|
32 | FileOutputStream fos = null;
|
---|
33 | ObjectOutputStream out = null;
|
---|
34 | try {
|
---|
35 | fos = new FileOutputStream(filename);
|
---|
36 | out = new ObjectOutputStream(fos);
|
---|
37 | out.writeObject(dataObject);
|
---|
38 | out.close();
|
---|
39 | } catch (IOException ex) {
|
---|
40 | ex.printStackTrace();
|
---|
41 | }
|
---|
42 | }
|
---|
43 |
|
---|
44 | @Override
|
---|
45 | public void help() {
|
---|
46 | Console.println("Usage: saveObject <filename> <objectName>");
|
---|
47 | }
|
---|
48 |
|
---|
49 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.