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

Last change on this file since 344 was 241, checked in by sherbold, 13 years ago
  • some changes to command parameter orders
  • removed command printRandomSesssion
  • renamed command loadSessionsFromClickstream do loadWebSequences
  • Property svn:mime-type set to text/plain
File size: 1.3 KB
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
13/**
14 * <p>
15 * Command to save the {@link GlobalDataContainer} through serialization.
16 * </p>
17 *
18 * @author Steffen Herbold
19 * @version 1.0
20 */
21public class CMDsave 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                FileOutputStream fos = null;
38                ObjectOutputStream out = null;
39                try {
40                        fos = new FileOutputStream(filename);
41                        out = new ObjectOutputStream(fos);
42                        out.writeObject(GlobalDataContainer.getInstance());
43                        out.close();
44                } catch (IOException ex) {
45                        Console.logException(ex);
46                }
47        }
48
49        /*
50         * (non-Javadoc)
51         *
52         * @see de.ugoe.cs.util.console.Command#help()
53         */
54        @Override
55        public void help() {
56                Console.println("Usage: save <filename>");
57        }
58
59}
Note: See TracBrowser for help on using the repository browser.