addressbook
Class FileSystem

java.lang.Object
  extended by addressbook.FileSystem

public class FileSystem
extends java.lang.Object

An object of this class manages interaction between the address book program and the file system of the computer it is running on.


Constructor Summary
FileSystem()
           
 
Method Summary
 java.lang.String getDefaultDirectory()
          Get the default directory for open/save/print
 AddressBook readFile(java.io.File file)
          Read a stored file
 void saveFile(AddressBook addressBook, java.io.File file)
          Save an address book to a file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileSystem

public FileSystem()
Method Detail

readFile

public AddressBook readFile(java.io.File file)
                     throws java.io.IOException,
                            java.lang.ClassNotFoundException
Read a stored file

Parameters:
file - the file specification for the file to read
Returns:
the AddressBook object stored in the file
Throws:
java.io.IOException - if there is a problem reading the file
java.lang.ClassCastException - if the file does not contain an AddressBook
java.lang.ClassNotFoundException - if the file does not contain an AddressBook, and the class it does contain is not found - this should never happen

saveFile

public void saveFile(AddressBook addressBook,
                     java.io.File file)
              throws java.io.IOException
Save an address book to a file

Parameters:
addressBook - the AddressBook to save
file - the file specification for the file to create
Throws:
java.io.IOException - if there is a problem writing the file

getDefaultDirectory

public java.lang.String getDefaultDirectory()
Get the default directory for open/save/print

Returns:
the default directory, or the user's home directory if there is none