String filename = prefs.get("maplocation", "") + prefix + tileId + ".png";
String filename = prefix + tile.getId() + ".png"; String path = prefs.get("maplocation", "") + filename;
    private static void writeTile(Tile tile, XMLWriter w) throws IOException {        w.startElement("tile");        int tileId = tile.getId();        w.writeAttribute("id", tileId);        //if (groundHeight != getHeight()) {        //    w.writeAttribute("groundheight", "" + groundHeight);        //}        writeProperties(tile.getProperties(), w);        Image tileImage = tile.getImage();        Preferences prefs = TiledConfiguration.node("saving");        boolean embedImages = prefs.getBoolean("embedImages", true);        boolean tileSetImages = prefs.getBoolean("tileSetImages", false);        // Write encoded data        if (tileImage != null && !tileSetImages) {            if (embedImages && !tileSetImages) {                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 (tileSetImages) {                w.startElement("image");                w.writeAttribute("id", tile.getImageId());                w.endElement();            } else {                String prefix = prefs.get("tileImagePrefix", "tile");                String filename = prefs.get("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();            }        }        if (tile instanceof AnimatedTile) {            writeAnimation(((AnimatedTile)tile).getSprite(), w);        }        w.endElement();    }