fork download
  1. import java.io.*;
  2. class Main{
  3. public static void main(String[] args) throws IOException, ClassNotFoundException{
  4. Object o = new int[]{10};
  5. oos.writeObject(o);
  6. oos.writeObject(o);
  7. {
  8. ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
  9. int[] o1 = (int[])ois.readObject();
  10. int[] o2 = (int[])ois.readObject();
  11. o1[0] += 5;
  12. System.out.println((o1==o2)+":"+o1[0]+" "+o2[0]);
  13. }
  14. {
  15. ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
  16. Object o1 = ois.readUnshared();
  17. System.out.println("2回目のreadUnshared");
  18. Object o2 = ois.readUnshared();
  19. }
  20. }
  21. }
Runtime error #stdin #stdout 0.04s 245824KB
stdin
Standard input is empty
stdout
true:15 15
2回目のreadUnshared