— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet429/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   425   426   427   428   429   430   431   432   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

ObjectInputStream is = new ObjectInputStream(fileIn);
checkboxState = (boolean[]) is.readObject();

} catch(Exception ex) {ex.printStackTrace();}
for (int i = 0; i < 256; i++) {
JCheckBox check = (JCheckBox) checkboxList.get(i);
if (checkboxState[i]) {
check.setSelected(true);
} else {
check.setSelected(false);
}

sequencer.stop(); 
buildTrackAndStart();

// close method

// close inner class
This is another inner class 
inside the BeatBox class.
Read the single object in the file (the 
boolean array) and cast it back to a 
boolean array (remember, readObject() 
returns a reference of type Object.
Now restore the state of each of the 
checkboxes in the ArrayList of actual 
JCheckBox objects (checkboxList).
Now stop whatever is currently playing, 
and rebuild the sequence using the new 
state of the checkboxes in the ArrayList.
deserializing the 
pattern
Sharpen your pencil
This version has a huge limitation! When you hit the “serializeIt” button, it 
serializes automatically, to a file named “Checkbox.ser” (which gets created if it 
doesn’t exist). But each time you save, you overwrite the previously-saved file.
Improve the save and restore feature, by incorporating a JFileChooser so that 
you can name and save as many different patterns as you like, and load/restore 
from any of your previously-saved pattern files.


serialization 
and
file I/O
you are here
4
465
Which of these do you think are, or should be, 
serializable? If not, why not? Not meaningful? 
Security risk? Only works for the current 
execution of the JVM? Make your best guess, 
without looking it up in the API.

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   425   426   427   428   429   430   431   432   ...   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