Lab 8: Serialization


Program to write

Design an interactive address book. Your address book must, upon invocation:
  1. Read in any address data from a binary file of your choosing in the current working directory, if the file exists;

  2. Display the number of addresses stored within the book;

  3. Provide the user a menu with options to

  4. Provide the user a way to exit, and, upon that selection,

  5. Serialize the entire address book to a file in the current directory.

Do not be overly concerned with what data fields you choose to represent in your book. First name, last name, and street address are sufficient for our purposes.

Do implement Serializable in whatever class you write to implement an individual entry in the book. (Vectors themselves are already serializable.) You might want to read this tutorial to familiarize yourself with serialization in java.

Also, create a sample database for your program that has at least five names, of which at least two have the same last name. Include this with your submission in your lab8 directory.


Design Advice


Question to answer

Answer the following in a comment block at the top of your code: Imagine if, after you've built up a large address book on disk, you decide to add an extra field to your entry class (e.g. you want to add a phone number field). What happens if you change the code, recompile, and run your program? Why? Don't just guess; try it and see.