From 26fa803ddb4407a09b5cc1eb606c567947679493 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Sun, 29 Jul 2007 17:22:32 +0000 Subject: [PATCH] added one more convenience method. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@3904 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/XmlFile.java | 28 ++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/hudson/XmlFile.java b/core/src/main/java/hudson/XmlFile.java index 13c76a7de7..891da916f1 100644 --- a/core/src/main/java/hudson/XmlFile.java +++ b/core/src/main/java/hudson/XmlFile.java @@ -9,24 +9,23 @@ import hudson.model.Descriptor; import hudson.util.AtomicFileWriter; import hudson.util.IOException2; import hudson.util.XStream2; +import org.xml.sax.Attributes; +import org.xml.sax.Locator; +import org.xml.sax.SAXException; +import org.xml.sax.ext.Locator2; +import org.xml.sax.helpers.DefaultHandler; -import javax.xml.parsers.SAXParserFactory; import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParserFactory; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; -import java.io.FileReader; +import java.io.Writer; import java.util.logging.Logger; -import org.xml.sax.helpers.DefaultHandler; -import org.xml.sax.SAXException; -import org.xml.sax.Locator; -import org.xml.sax.Attributes; -import org.xml.sax.ext.Locator2; - /** * Represents an XML data file that Hudson uses as a data file. * @@ -164,6 +163,19 @@ public final class XmlFile { return new InputStreamReader(new FileInputStream(file),sniffEncoding()); } + /** + * Writes the raw XML to the given {@link Writer}. + * Writer will not be closed by the implementation. + */ + public void writeRawTo(Writer w) throws IOException { + Reader r = readRaw(); + try { + Util.copyStream(r,w); + } finally { + r.close(); + } + } + /** * Parses the beginning of the file and determines the encoding. *