Modify the TelephoneNumber class described in Exercise 6 so that it is serializable. Write a program that creates an array whose base type is TelephoneNumber by reading data from the keyboard. Write the array to a binary file using the method writeObject. Then read the data from the file using the method readObject and display the information to the screen. Allow the user to change, add, or delete any telephone number until he or she indicates that all changes are complete. Then write the modified telephone numbers to the file, replacing its original contents.

One difficulty in the solution to this project is that we have not yet seen the collection classes. We will read the telephone numbers into an array. We either need to determine the number of objects in the file or expand the array as we read the objects. This solution reads the file twice, once to determine the number of objects and then to read the objects into an appropriately sized array.

Once this is done, we make a single change and then write the file back out.


See the code in SerializedTelephoneNumber.java, SerializedTelephoneProgram.java, MissingTelephoneInputFileException.java and the data file numbers.data.

Computer Science & Information Technology

You might also like to view...

The following sequence of commands is needed to perform the given task.

What will be an ideal response?

Computer Science & Information Technology

Why is it important to check your system configuration before installing openSUSE?

What will be an ideal response?

Computer Science & Information Technology

Text that distinguishes one form control from another is called a ____.

A. label B. value C. script D. none of the above

Computer Science & Information Technology

It is a good idea to use a passphrase and replace some letters with numbers and symbols

Indicate whether the statement is true or false.

Computer Science & Information Technology