AddressBook - import java.util i import java.io import...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.util.*; import java.io.*; i import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; i public class AddressBook implements Serializable{ p private static final long serialVersionUID = 1L; private ArrayList<BuddyInfo> buddies; p public AddressBook(){ buddies = new ArrayList<BuddyInfo>(); } public void addBuddy(BuddyInfo bi){ this.buddies.add(bi); } public void removeBuddy(BuddyInfo bi){ this.buddies.remove(bi); } public int getSize(){ return buddies.size(); } public void clear(){ buddies.clear(); } @Override public String toString(){ String s = ""; for(BuddyInfo bi : buddies){ s += bi + "\n"; } return s; } public void writeObject(File f){ try { ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(f)); oos.writeObject(this); oos.close(); } catch (Exception e) { e.printStackTrace(); } } public String toXML(){ String s = "<AddressBook>\n"; for(BuddyInfo bi : buddies){ s += bi.toXML(); } return s + "</AddressBook>"; } public void writeXML(File f){
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/13/2010 for the course SYSC 2101 taught by Professor Babac during the Winter '10 term at Carleton CA.

Page1 / 3

AddressBook - import java.util i import java.io import...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online