全文预览

面向对象程序设计(Java)复习提纲

上传者:学习一点 |  格式:doc  |  页数:10 |  大小:58KB

文档介绍
如何编程?DataInputStreamin=?newDataInputStream(?newBufferedInputStream( newFileInputStream("Data.txt");DataOutputStreamout=?newDataOutputStream(?newBufferedOutputStream( newFileOutputStream("Data.txt");面向字符流的文件和控制台的读写如何编程?读控制台BufferedReaderstdIn=newBufferedReader(newInputStreamReader(System.in));Stringinput=stdIn.readLine();写控制台:PrintWriterstdOut=newPrintWriter(System.out,true);stdOut.println(“”);读文件:BufferedReaderfileIn=newBufferedReader(newFileReader(“filename”));Stringline=fileIn.readLine();写文件:newPrintWriter(newFileWriter(“filename”)); fileOut.println("Alineofoutput.");参考:privatevoidwriteFile(Stringfilename,Stringcontent)throwsIOException{Filefile=newFile(filename); if(!file.exists()){ file.createNewFile();}PrintWriterfileOut=newPrintWriter(file);fileOut.println(content);fileOut.close();?}

收藏

分享

举报
下载此文档