Read write Object in Java