import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.nio.charset.*;
import java.util.concurrent.Callable;

public class TestSerial {
	public static class ABCâ implements Serializable {
		public String msg;
		public ABCâ() {
			msg = "Hello world";
		}
		public static Callable<ABCâ> getHello() {
			return (Callable<ABCâ> & Serializable) () -> {
				return new ABCâ();
			};
		}
	}

    private static <T> T reserialize(T o) throws IOException {
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		ObjectOutputStream oos = new ObjectOutputStream(baos);
		
		oos.writeObject(o);
		
		oos.close();
		
		ObjectInputStream iis = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
		
		try {
			o = (T)iis.readObject();
		} catch (ClassNotFoundException e) {
			throw new IOException(e);
		}
		iis.close();
		return o;
    }
    
    public static void main(String a[]) throws Exception{
	System.out.println(Charset.defaultCharset());
	Callable<ABCâ> foo = ABCâ.getHello();
        ABCâ hello = new ABCâ();
        ABCâ rh = reserialize(hello);
        System.out.println(rh.msg);
        reserialize(foo).call();
	}
}

