提交 82fe6741 编写于 作者: K kohsuke

added a method to read XML in the proper encoding.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@3902 71c3de6d-444a-0410-be80-ed276b4c234a
上级 e334c7b3
......@@ -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 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册