Code stream (file-based) works
/*
* To change this template, choose Tools
fog = new File ("fileOggetti.fog"); What
c = null;
What thing = null;
Line2D.Double Line2D.Double l = new ((double) (new java.util.Random ()). nextInt (15),
(double) (new java.util.Random ()). nextInt (15),
(double) (new java.util.Random ()). nextInt (15),
(double) ( new java.util.Random ()). nextInt (15));
try {fos = new FileOutputStream (fog);
fobjos = new ObjectOutputStream (fos);
} catch (IOException e) {e.printStackTrace ( );}
What do
= new ();
cosa.descrizione = "a bunch of nice words"
try {/ / write an object file
fobjos.writeObject (what);
/ / Reset the stream
fobjos. reset ();
/ / change the state of what
cosa.descrizione = "a bunch of bad words";
/ / write back the same object file
fobjos.writeObject (what);
fobjos.writeObject (l);
} catch (IOException e) {e.printStackTrace ();}
FileInputStream fis = null;
ObjectInputStream fobjis = null;
try {fis = new FileInputStream (fog);
} catch (FileNotFoundException e) {e.printStackTrace ();} try {
fobjis = new ObjectInputStream (fis);
} catch (IOException e) {e.printStackTrace ();}
try {/ / read a file from the first time
c = (What) fobjis.readObject ();
System.out.println ("first item" + c.descrizione )
/ / read a second time from the file
c = (What) fobjis.readObject ();
System.out.println ("second subject" c.descrizione +);
/ / note that the status of this item? different
Line2D.Double l1 = (Line2D.Double) fobjis.readObject ();
System.out.println ("a line with one end in" + l1.x1)
} catch (Exception e) {e. printStackTrace ();}}
}
0 comments:
Post a Comment