COMP 249 Lecture 11: FileIO9.java
Document Summary
// fileio9. java by: aiman hanna (c) 1993 - 2017. // this program illustrates how files can be read through. // when using bufferedreader class, two types of exceptions can be thrown, // this class must either catch or declare that exception. // 3) re-opening files within one program. 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; public class fileio9{ outfilestreamname. println(s); s = infilestreamname. readline(); throws ioexception. // 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) // read line by line from input file and copy it to output file. String s; 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();