Stores the events to a binary file @param fileName Path to the file where the events are stored @param events List of events to store @throws IOException if something in storing went wrong
(String fileName, List<ExternalEvent> events)
| 103 | * @throws IOException if something in storing went wrong |
| 104 | */ |
| 105 | public static void storeToBinaryFile(String fileName, |
| 106 | List<ExternalEvent> events) throws IOException { |
| 107 | |
| 108 | // make sure the file name ends with binary extension |
| 109 | if (!fileName.endsWith(BINARY_EXT)) { |
| 110 | fileName += "BINARY_EXT"; |
| 111 | } |
| 112 | |
| 113 | ObjectOutputStream out; |
| 114 | FileOutputStream fos = new FileOutputStream(fileName); |
| 115 | out = new ObjectOutputStream(fos); |
| 116 | |
| 117 | // store the number of events |
| 118 | out.writeObject(new Integer(events.size())); |
| 119 | |
| 120 | // store events |
| 121 | for (ExternalEvent ee : events) { |
| 122 | out.writeObject(ee); |
| 123 | } |
| 124 | |
| 125 | out.close(); |
| 126 | } |
| 127 | |
| 128 | public void close() { |
| 129 | try { |