Last change
on this file since 130 was
88,
checked in by sherbold, 13 years ago
|
+ added commands save and load that saves, respectively loads the internal data
|
-
Property svn:mime-type set to
text/plain
|
File size:
1009 bytes
|
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 CMDsave implements Command {
|
---|
14 |
|
---|
15 | @Override
|
---|
16 | public void run(List<Object> parameters) {
|
---|
17 | String filename;
|
---|
18 | try {
|
---|
19 | filename = (String) parameters.get(0);
|
---|
20 | }
|
---|
21 | catch (Exception e) {
|
---|
22 | throw new InvalidParameterException();
|
---|
23 | }
|
---|
24 |
|
---|
25 |
|
---|
26 | FileOutputStream fos = null;
|
---|
27 | ObjectOutputStream out = null;
|
---|
28 | try {
|
---|
29 | fos = new FileOutputStream(filename);
|
---|
30 | out = new ObjectOutputStream(fos);
|
---|
31 | out.writeObject(GlobalDataContainer.getInstance());
|
---|
32 | out.close();
|
---|
33 | } catch (IOException ex) {
|
---|
34 | ex.printStackTrace();
|
---|
35 | }
|
---|
36 | }
|
---|
37 |
|
---|
38 | @Override
|
---|
39 | public void help() {
|
---|
40 | Console.println("Usage: saveObject <filename>");
|
---|
41 | }
|
---|
42 |
|
---|
43 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.