Enumeration keys = tile.getProperties(); while(keys.hasMoreElements()) { String key = (String) keys.nextElement();
Properties props = tile.getProperties(); for (Enumeration keys = props.keys(); keys.hasMoreElements();) { String key = (String)keys.nextElement();
    private void writeTile(Tile tile, XMLWriter w) throws IOException {        try {            w.startElement("tile");            int tileId = tile.getId();            w.writeAttribute("id", "" + tileId);            //if (groundHeight != getHeight()) {            //    w.writeAttribute("groundheight", "" + groundHeight);            //}            Enumeration keys = tile.getProperties();            while(keys.hasMoreElements()) {                String key = (String) keys.nextElement();                w.startElement("property");                w.writeAttribute("name", key);                w.writeAttribute("value", tile.getPropertyValue(key));                w.endElement();            }            Image tileImage = tile.getImage();            TiledConfiguration conf = TiledConfiguration.getInstance();            // Write encoded data            if (tileImage != null && !conf.keyHasValue(                        "tmx.save.tileSetImages", "1")) {                if (conf.keyHasValue("tmx.save.embedImages", "1")                        && conf.keyHasValue("tmx.save.tileSetImages", "0")) {                    w.startElement("image");                    w.writeAttribute("format", "png");                    w.startElement("data");                    w.writeAttribute("encoding", "base64");                    w.writeCDATA(new String(Base64.encode(                                    ImageHelper.imageToPNG(tileImage))));                    w.endElement();                    w.endElement();                } else if(conf.keyHasValue("tmx.save.tileSetImages", "1")) {                    w.startElement("image");                    w.writeAttribute("id", "" + tile.getImageId());                    int orientation = tile.getImageOrientation();                    int rotation = 0;                    boolean flipped =                        (orientation & 1) == ((orientation & 2) >> 1);                    if ((orientation & 4) == 4) {                        rotation = ((orientation & 1) == 1) ? 270 : 90;                    } else {                        rotation = ((orientation & 2) == 2) ? 180 : 0;                    }                    if (rotation != 0) w.writeAttribute("rotation",                            "" + rotation);                    if (flipped) w.writeAttribute("flipped", "true");                    w.endElement();                } else {                    String prefix = conf.getValue("tmx.save.tileImagePrefix");                    String filename = conf.getValue("tmx.save.maplocation") +                        prefix + tileId + ".png";                    w.startElement("image");                    w.writeAttribute("source", prefix + tileId + ".png");                    FileOutputStream fw = new FileOutputStream(                            new File(filename));                    byte[] data = ImageHelper.imageToPNG(tileImage);                    fw.write(data, 0, data.length);                    fw.close();                    w.endElement();                }            }            w.endElement();        } catch (XMLWriterException e) {            e.printStackTrace();        }    }