COMP 249 Lecture 11: FileIO10

41 views5 pages

Document Summary

This program provides a pre-introduction to file class. The program actually does not introduce that class; rather it explain why it is needed. See fileio11. java for more information. import java. util. scanner; import java. io. printwriter; import java. io. fileoutputstream; import java. io. filenotfoundexception; import java. io. fileinputstream; import java. io. bufferedreader; import java. io. filereader; import java. io. ioexception; throws ioexception. // declare the ioexception exception public class fileio10{ // read line by line from input file and copy it to output file. // a method that the names of an input and output files (as streams) // then copies the input file to the output file public static void filecopy(bufferedreader infilestreamname, printwriter outfilestreamname) s = infilestreamname. readline(); while(s != null) // the readline() method returns null when it is eof. // must close the files to flush the buffers infilestreamname. close(); outfilestreamname. close(); outfilestreamname. println(s); s = infilestreamname. readline(); // a method that takes a stream file name and display the contents of this file public static void displayfilecontents(bufferedreader infilestreamname) throws ioexception.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents