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