— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet396/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   392   393   394   395   396   397   398   399   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

puzzle 
answers


this is a new chapter
429
14

serialization 
and 
file I/O
Objects can be flattened and inflated. 
Objects have state and behavior. 
Behavior lives in the class, but state lives within each individual object. So what happens when 
it’s time to save the state of an object? If you’re writing a game, you’re gonna need a Save/
Restore Game feature. If you’re writing an app that creates charts, you’re gonna need a Save/
Open File feature. If your program needs to save state, you can do it the hard way, interrogating 
each object, then painstakingly writing the value of each instance variable to a file, in a 
format you create. Or, you can do it the easy OO way—you simply freeze-dry/flatten/persist/
dehydrate the object itself, and reconstitute/inflate/restore/rehydrate it to get it back. But you’ll 
still have to do it the hard way sometimes, especially when the file your app saves has to be read 
by some other non-Java application, so we’ll look at both in this chapter.
If I have to read 
one more fi le full of 
data, I think I’ll have to kill him. He 
knows I can save whole objects, but 
does he let me? 
NO, that would be 
too easy. Well, we’ll just see how 
he feels after I...
Saving Objects
Make it Stick


430
 
chapter 14
You’ve made the perfect pattern. You want to save the pattern. 
You could grab a piece of paper and start scribbling it down, but 
instead you hit the Save button (or choose Save from the File 
menu). Then you give it a name, pick a directory
and exhale knowing that your masterpiece won’t go 
out the window with the blue screen of death. 
You have lots of options for how to save the state of 
your Java program, and what you choose will probably 
depend on how you plan to use the saved state. Here 
are the options we’ll be looking at in this chapter.

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   392   393   394   395   396   397   398   399   ...   555




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish