Advertisement
Guest User

seminar5

a guest
Mar 24th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. package eu.ase.io.serilization;
  2.  
  3. import java.io.FileOutputStream;
  4. import java.io.IOException;
  5. import java.io.ObjectOutputStream;
  6. import java.net.URL;
  7.  
  8. public class ObjectsSave {
  9.  
  10.    
  11.    
  12.     public static void main(String[] args){
  13.        
  14.         ObjectsGraph og = null;
  15.        
  16.         try{
  17.             System.out.println("Saving objects ...");
  18.             ObjectOutputStream sout = new ObjectOutputStream(new FileOutputStream("test4.txt"));
  19.             URL o1 = new URL("http://www.google.com");
  20.             URL o2 = o1;
  21.             URL o3 = o1;
  22.            
  23.             og = new ObjectsGraph(o1, o2);
  24.             sout.writeObject(og);
  25.             //sout.reset();
  26.             sout.writeObject(o3);
  27.             sout.flush();
  28.            
  29.             System.out.println("og written: " + og);
  30.             System.out.println("o3: " + o3);
  31.            
  32.             boolean exp = ( (og.o1 == o3) && (og.o1 == og.o2) );
  33.             System.out.println("Exp b: " + exp);
  34.            
  35.             sout.close();
  36.        
  37.         }
  38.         catch(IOException e){
  39.             e.printStackTrace();
  40.         }
  41.        
  42.     }
  43.    
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement