资源描述:
《西农java英语实习题目》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Lab4Inthislab,youwillpracticehowtousethefollowingclasses:lBufferedReaderandBufferedWriterlBufferedOutputStreamandBufferedIutputStream(SimilartoBufferedReaderandBufferedWriter,Iamsureyoucanhandlethem.)lFileOutputStreamandFileInputStreamlDataOutputStreaman
2、dDataInputStreamlRandomAccessFilelObjectInputStreamandObjectOutputStreamTask1.CreateaclassMyLoganditimplementsoneinterfacecalledLoggable.Thisclassisusedtoreadandwrite“MyLog.log”whichcontains:thecurrenttime,thelogtypeandthecontent.ThedefinitionofLoggablei
3、sasfollows:interfaceLoggable{//Threelogtypes:NFORMATION,WARNING,ERRORenumTYPE{INFORMATION,WARNING,ERROR};//Addonelog,includinglogtypeandlogcontent.voidaddLog(Loggable.TYPEtype,StringlogContent);//Showallthelogsinthelogfile.voidreadLog();}Therequirementsa
4、re:lWhennewlogsareaddedusingaddLog(),theyshouldbeappendedtothelogfile.Forexample:lWhenusingreadLog()toshowallthelogsintheconsole,convertallthelowercasecharactersintouppercasecharactersforthecontentsofeachlog.Forexample:******************************2010-
5、12-2514:40:02INFORMATIONTHISISACONTENTSTRING************************************************************2010-12-2514:45:02INFORMATIONTHISISACONTENTSTRING******************************Tips:lUseBufferedReaderandBufferedWritertoreadandwritethelogfile.lToget
6、theenumvalue,use:type.toString()intheaddLog().lPayattentiontothedateformat,youmayusetheclass:SimpleDateFormat.Task2.UseFileOutputStreamandBufferedOutputStreamseparatelytowrite1,000,000randomnumbers(double)intoabinaryfile(Numbers.dat)andcomparethetimeexpe
7、nses.WritetheresultsanderrormessagesintoMyLog.log(itisthesamelogfileasintheTask1).lTheresultisasfollows:lThecontentofthelogfileisasfollows:******************************2011-11-2815:06:57INFORMATIONDone,cost573withoutbuffer*******************************
8、*****************************2011-11-2815:06:57INFORMATIONDone,cost9withbuffer************************************************************2010-12-0515:07:04ERRORAccessDeny!!!******************************lAfterchangingtheN