I have created an xml file and I want to save it to my desktop but I have no clue how to do that type of thing.
here is my code thus far:
// create xml
        DocumentBuilderFactory factory =
            DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        Document testDoc = builder.newDocument();
        Element bo = testDoc.createElement("bo");
        bo.setAttribute("type", "Employee");
        bo.setAttribute("id", emp.getId());
        testDoc.appendChild(bo);
        Element username = testDoc.createElement("username");
        username.setTextContent(emp.getUsername());
        bo.appendChild(username);
        Element passHash = testDoc.createElement("passwordHash");
        passHash.setTextContent(emp.getPasswordHash());
        bo.appendChild(passHash);
        Element passwordSalt = testDoc.createElement("passwordSalt");
        passwordSalt.setTextContent(emp.getPasswordSalt());
        bo.appendChild(passwordSalt);
        Element name = testDoc.createElement("name");
        name.setTextContent(emp.getName());
        bo.appendChild(name);
        Element lastLogin = testDoc.createElement("lastLogin");
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println("date = " + emp.getLastLogin());
        String date = df.format(emp.getLastLogin());
        lastLogin.setTextContent(date);
        bo.appendChild(lastLogin);
        DOMSource source = new DOMSource(testDoc);
        PrintStream ps = new PrintStream(emp.getId() + ".xml");
        StreamResult result = new StreamResult(ps);
        TransformerFactory transformerFactory = TransformerFactory
            .newInstance();
        Transformer transformer = transformerFactory.newTransformer();
        transformer.transform(source, result);
Thanks,
 
     
    