Coding the ContactLoader class

We've already seen that ContactLoader should have a single method loadContacts() , which takes as argument the file name and returns a list of Contacts:

    public List<Contact> loadContacts(String fileName) {

}

In the method, we initialize a new instance of XmlUtil and use the loadXmlFile method to get the XML Document object:

    XmlUtil xmlUtil = new XmlUtil();
Document doc = xmlUtil.loadXmlFile(fileName);

Now what's left is processing the resulting DOM object structure and constructing the list of contacts in the model type we need. Again, to avoid getting into too much detail about XML, I'll just point you to the bundled source code at 05-jdk-modules/src/packt.contact.

There are a couple of problems with the packt.contact module right now--shared classes and dependency leakage. One of which you might have already noticed.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.227.72.15