diff --git a/core/src/main/java/hudson/XmlFile.java b/core/src/main/java/hudson/XmlFile.java index bf6fc23bd559e524876f22e8a4c0d3257e38414e..13c76a7de71d0a854a68eb250f95bae510eac6a2 100644 --- a/core/src/main/java/hudson/XmlFile.java +++ b/core/src/main/java/hudson/XmlFile.java @@ -18,6 +18,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; +import java.io.FileReader; import java.util.logging.Logger; import org.xml.sax.helpers.DefaultHandler; @@ -154,11 +155,22 @@ public final class XmlFile { return file.toString(); } + /** + * Opens a {@link Reader} that loads XML. + * This method uses {@link #sniffEncoding() the right encoding}, + * not just the system default encoding. + */ + public Reader readRaw() throws IOException { + return new InputStreamReader(new FileInputStream(file),sniffEncoding()); + } + /** * Parses the beginning of the file and determines the encoding. * * @throws IOException * if failed to detect encoding. + * @return + * always non-null. */ public String sniffEncoding() throws IOException { class Eureka extends SAXException {