go to previous page   go to home page   go to next page

Answer:


Using File Objects with Stream Constructors

Previous examples of I/O streams used constructors that took String arguments. Some constructors for I/O streams use a File argument. Here is a list of them:

FileInputStream(File file) throws IOException

FileOutputStream(File file) throws IOException

FileReader(File file) throws FileNotFoundException
 
FileWriter(File file) throws FileNotFoundException

Here is more of the improved file copy program, now with blanks to fill in the constructors:


import java.io.*;
class CopyBytes
{
  public static void main ( String[] args ) 
  {
    DataInputStream  instr;
    DataOutputStream outstr;
    . . . .

    File inFile  = new File( args[0] );
    File outFile = new File( args[2] );

    . . . .

    try
    {
      instr = 
        new DataInputStream(
          new BufferedInputStream(
            new FileInputStream(  )));

      outstr = 
        new DataOutputStream(
          new BufferedOutputStream(
            new FileOutputStream(   )));
    . . . .

  }
}

QUESTION 8:

Cut and paste from the following phrases:

inFile
outFile

go to previous page   go to home page   go to next page