Java Serialization Example

This code illustrates marking a class as Serializable so it can be written to and read from a file easily. This is also useful if transmitting data via RMI. Build the solution by typing
        javac Phones.java
Run the solution by typing
        java -ea Phones add zoe 555-9876
or the like. The -ea option enables assertion checking, which is helpful during development.

For example (where % marks lines entered by the user):

        ls phone-book.dat
        /bin/ls: phone-book.dat: No such file or directory
        % java -ea Phones add zoe 555-9876
        % java -ea Phones get zoe
        Phone # for zoe: 555-9876
        % java -ea Phones get rich
        No phone entry for rich
        % java -ea Phones add zoe 555-6789
        % java -ea Phones get zoe
        Phone # for zoe: 555-6789