Reading Data from a File
10. Opening Files
Answer:
Yes.
Opening Files
Look at the openFiles()
method. It opens a BufferedReader
stream with the source file and a PrintWriter
with the destination file. Decide what should go in each box, and click it to verify your choice.
class CopyMaker { String sourceName, destName; BufferedReader source; PrintWriter dest; String line; // return true if both files open, otherwise return false // private boolean openFiles() { // open the source try { source = new (new FileReader( sourceName )); } catch ( iox ) { System.out.println("Problem opening " + sourceName ); return false; } // open the destination try { dest = new PrintWriter( new (new FileWriter( destName )) ); } catch ( iox ) { System.out.println("Problem opening " + destName ); return false; } return ; } . . . . . the rest of the program . . . . . } |
Question 10:
Click in the blanks.