Changeset 1523 in josm for trunk/src/org/openstreetmap/josm/io/XmlWriter.java
- Timestamp:
- 2009-04-06T20:18:48+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/XmlWriter.java
r1169 r1523 2 2 package org.openstreetmap.josm.io; 3 3 4 import java.io.OutputStream;5 import java.io.OutputStreamWriter;6 4 import java.io.PrintWriter; 7 import java.io.UnsupportedEncodingException;8 5 import java.util.HashMap; 9 6 … … 15 12 public class XmlWriter { 16 13 17 /** 18 * The interface to write the data into an Osm stream 19 * @author immanuel.scholz 20 */ 21 public static interface OsmWriterInterface { 22 void header(PrintWriter out); 23 void write(PrintWriter out); 24 void footer(PrintWriter out); 25 } 26 27 28 protected XmlWriter(PrintWriter out) { 14 protected PrintWriter out; 15 16 public XmlWriter(PrintWriter out) { 29 17 this.out = out; 30 18 } 31 19 32 20 /** 33 21 * Encode the given string in XML1.0 format. … … 49 37 50 38 /** 51 * Write the header and start tag, then call the runnable to add all real tags and finally52 * "closes" the xml by writing the footer.53 */54 public static void output(OutputStream outStream, OsmWriterInterface outputWriter) {55 PrintWriter out;56 try {57 out = new PrintWriter(new OutputStreamWriter(outStream, "UTF-8"));58 } catch (UnsupportedEncodingException e) {59 throw new RuntimeException(e);60 }61 out.println("<?xml version='1.0' encoding='UTF-8'?>");62 outputWriter.header(out);63 outputWriter.write(out);64 outputWriter.footer(out);65 out.flush();66 out.close();67 }68 69 /**70 39 * The output writer to save the values to. 71 40 */ 72 protected final PrintWriter out;73 41 final private static HashMap<Character, String> encoding = new HashMap<Character, String>(); 74 42 static {
Note:
See TracChangeset
for help on using the changeset viewer.