Writer writer = new OutputStreamWriter(os); XMLWriter xmlWriter = new XMLWriter(writer);  xmlWriter.startDocument(); writeMap(map, xmlWriter, filename); xmlWriter.endDocument();  writer.flush();
writeMap(map, os);
    public void writeMap(Map map, String filename) throws IOException {        FileOutputStream os = new FileOutputStream(filename);        Writer writer = new OutputStreamWriter(os);        XMLWriter xmlWriter = new XMLWriter(writer);        xmlWriter.startDocument();        writeMap(map, xmlWriter, filename);        xmlWriter.endDocument();        writer.flush();    }