— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet417/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   413   414   415   416   417   418   419   420   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

452
 
chapter 14
The 
java.io.File
class
The java.io.File class represents a fi le on disk, but doesn’t 
actually represent the contents of the fi le. What? Think of 
a File object as something more like a pathname of a fi le 
(or even a directory) rather than The Actual File Itself. 
The File class does not, for example, have methods for 
reading and writing. One VERY useful thing about a File 
object is that it offers a much safer way to represent a 
fi le than just using a String fi le name. For example, most 
classes that take a String fi le name in their constructor 
(like FileWriter or FileInputStream) can take a File 
object instead. You can construct a File object, verify 
that you’ve got a valid path, etc. and then give that File 
object to the FileWriter or FileInputStream.
writing 
files
50,Elf,bow, sword,dust
200,Troll,bare hands,big ax
120,Magician,spells,invisibility

File
object represents the name 
and path of a fi le or directory on 
disk, for example:
/Users/Kathy/ Data/GameFile.txt
But it does NOT represent, or give 
you access to, the data 
in the fi le!
Some things you can do with a File object:
GameFile.txt
A File object does NOT 
represent (or give you 
direct access to) the 
data inside the file!
A File object represents the 
filename “GameFile.txt”
File f = new File(“MyCode.txt”); 
Make a File object representing an 
existing fi le
1
File dir = new File(“Chapter7”); 
dir.mkdir();
Make a new directory
2
if (dir.isDirectory()) {
String[] dirContents = dir.list();
for (int i = 0; i < dirContents.length; i++) {

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   413   414   415   416   417   418   419   420   ...   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