added one more convenience method.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@3904 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
kohsuke committed 2007-07-29 17:22:32 +00:00
1 parent d4304e19e4
commit 26fa803ddb
1 file changed
+20 -8
+20 -8
View File
@@ -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.
*