CSci 161 Lab #2
 

Code a Java class named Lab2 which will:

  • open a file of Objects for input, read the Objects in the file and do the following:
    • count of number of Integer and Long objects and total them
    • count the number of Double and Float objects and total them
    • count the number of Character objects and concatenate them
    • count the number of "other" objects
    • output the results of the above processing steps
  • open a binary file for input and do the following:
    • read all the file data using the readDouble method of DataInputStream
    • Count the items and compute their sum. Output the result.
    • close the file and open it again, to reset the file pointer to the file beginning.
    • read all the file data using the readInt method of DataInputStream
    • Count the items and compute their sum. Output the result.

You will need to use the instanceof operator to identify certain object types in the object input stream. You will also need an ObjectInputStream to read data from the input file.

You will need to handle the end-of-file exceptions when they occur, so that you can terminate the processing of input and display your results.

Your lab instructor will give you the name of an object input file. Your main routine, when activated, should receive this file name as the first command line parameter. Your lab instructor will also give you the name of a binary input file. Your main routine, when activated, should receive this file name as the second command line parameter.

Use this file as a starting point.

 
When you are finished, ask your lab instructor to check your work and record your scores.