文档详情

java语言程序设计解答例题复习题答案.pdf

发布:2025-06-13约1.29万字共6页下载文档
文本预览下载声明

Chapter19BinaryI/O

1.Althoughitisnottechnicallyprecise,atextfileconsistsofasequenceof

charactersandabinaryfileconsistsofasequenceofbits.Youcanuseatext

editortoviewatextfile,butnotabinaryfile.

2.YouhavetouseJavaI/Oclassestocreateobjectsandusethemethodsinthe

objectstoperformI/O.AJavaI/Oobjectiscalledastream.Anobjectforreading

dataiscalledaninputstreamandanobjectforwritingdataiscalledanoutput

stream.

3.BinaryI/Oreadsabytefromafileandcopiesitdirectlytothememorywithany

conversion,viceversa.TextI/Orequiresencodinganddecoding.TheJVM

convertsaUnicodetoafilespecificencodingwhenwritingacharacterand

covertsafilespecificencodingtoaUnicodewhenreadingacharacter.

4.CharactersarerepresentedusingUnicodeinthememoryandcharactersare

representedinafileusingaspecifiedencodingscheme.Ifnoencodingschemeis

specified,thesystem’sdefaultencodingschemeisused.

5.Thevaluesstoredinthetextfileare0x410x420x43.

6.Ifyouwritestring100toanASCIItextfile,thevaluesstoredare0x310x30

0x30.Ifyouwriteanumericbyte-typevalue100usingbinaryI/O,thevalue

storedinthefileis0x64.

7.TheencodingschemeforrepresentingacharacterinaJavaprogramisthe

Unicode.Bydefault,atextfileisencodedusingASCII.

8.AlmostallthemethodsandconstructorsinJavaI/Oclasses,becausethereare

显示全部
相似文档