source: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDsave.java @ 134

Last change on this file since 134 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 
1package de.ugoe.cs.eventbench.commands;
2
3import java.io.FileOutputStream;
4import java.io.IOException;
5import java.io.ObjectOutputStream;
6import java.security.InvalidParameterException;
7import java.util.List;
8
9import de.ugoe.cs.eventbench.data.GlobalDataContainer;
10import de.ugoe.cs.util.console.Command;
11import de.ugoe.cs.util.console.Console;
12
13public 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.