1 package org.simantics.acorn;
3 import java.io.Externalizable;
4 import java.io.IOException;
5 import java.io.ObjectInput;
6 import java.io.ObjectOutput;
7 import java.io.ObjectOutputStream;
8 import java.nio.file.Files;
9 import java.nio.file.Paths;
10 import java.nio.file.StandardOpenOption;
12 public class ExternalizableExample implements Externalizable {
17 public ExternalizableExample(int first, long second) {
23 public void writeExternal(ObjectOutput out) throws IOException {
25 out.writeLong(second);
29 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
34 public static void main(String[] args) {
35 Externalizable test = new ExternalizableExample(123, 3456);
37 try (ObjectOutputStream stream = new ObjectOutputStream(Files.newOutputStream(Paths.get("C:/Users/Jani Simomaa/Desktop/test"), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING))) {
38 stream.writeObject(test);
39 } catch (IOException e) {