Serialization Allows you to turn Java Objects into serial data that can be either save to a file or...
-
Upload
randall-hart -
Category
Documents
-
view
215 -
download
1
Transcript of Serialization Allows you to turn Java Objects into serial data that can be either save to a file or...
![Page 1: Serialization Allows you to turn Java Objects into serial data that can be either save to a file or sent over a network. Usefull for persisting data.](https://reader036.fdocuments.us/reader036/viewer/2022082713/5697c00d1a28abf838cc9a4d/html5/thumbnails/1.jpg)
Serialization
Allows you to turn Java Objects into serial data that can be either save to a file or sent over a network.
Usefull for persisting data.
![Page 2: Serialization Allows you to turn Java Objects into serial data that can be either save to a file or sent over a network. Usefull for persisting data.](https://reader036.fdocuments.us/reader036/viewer/2022082713/5697c00d1a28abf838cc9a4d/html5/thumbnails/2.jpg)
Serialization Syntax
FileOutputStream filOut = new FileOutputStream("gamestate.ser"); ObjectOutputStream out = new ObjectOutputStream(filOut); out.writeObject(gst); out.close(); filOut.close();
![Page 3: Serialization Allows you to turn Java Objects into serial data that can be either save to a file or sent over a network. Usefull for persisting data.](https://reader036.fdocuments.us/reader036/viewer/2022082713/5697c00d1a28abf838cc9a4d/html5/thumbnails/3.jpg)
Deserialization Syntax
FileInputStream filIn = new FileInputStream("gamestate.ser"); ObjectInputStream ois = new
ObjectInputStream(filIn); gst= (GameState) ois.readObject(); ois.close(); filIn.close();
![Page 4: Serialization Allows you to turn Java Objects into serial data that can be either save to a file or sent over a network. Usefull for persisting data.](https://reader036.fdocuments.us/reader036/viewer/2022082713/5697c00d1a28abf838cc9a4d/html5/thumbnails/4.jpg)
Ant Build Tool
Ant is integrated into Eclipse
Ant allows you to build, copy files, deploy files, generate jar files, etc.
![Page 5: Serialization Allows you to turn Java Objects into serial data that can be either save to a file or sent over a network. Usefull for persisting data.](https://reader036.fdocuments.us/reader036/viewer/2022082713/5697c00d1a28abf838cc9a4d/html5/thumbnails/5.jpg)
Ant exe-JAR
1/ right-click your project in eclipse project- or package-explorer and select Export
2/ Select the AntBuildfiles from the General directory
3/ accept the defaults, and make sure both check boxes are selected.
4/ Select Window || Show View || Ant5/ drag your build.xml file into the Ant view. 6/ open up the build.xml file in the editor
![Page 6: Serialization Allows you to turn Java Objects into serial data that can be either save to a file or sent over a network. Usefull for persisting data.](https://reader036.fdocuments.us/reader036/viewer/2022082713/5697c00d1a28abf838cc9a4d/html5/thumbnails/6.jpg)
Ant exe-JAR
7/ add the below target (next slide) within the enclosing <project> </project> tags
8/ save the build.xml. click on the jar target in the Ant view and click run
9/ refresh your project by clicking F5 and you will see the generated executable jar.
![Page 7: Serialization Allows you to turn Java Objects into serial data that can be either save to a file or sent over a network. Usefull for persisting data.](https://reader036.fdocuments.us/reader036/viewer/2022082713/5697c00d1a28abf838cc9a4d/html5/thumbnails/7.jpg)
SwingWorkerSwingWorker takes two Object parameters.
+The first is the return value and is passed to done()+The second parameter is the progress value and is
passed to publish/process.
Example: SwingWorker<Boolean, Integer>
There are three important methods of SwingWorker.+doInBackGround() --background thread+process() -main UI thread+done() -main UI thread