mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-11 11:06:25 +00:00
added a method to read it into a string.
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@3908 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
8c4f9f6094
commit
2f99ea2605
1 file changed
+10
@@ -24,6 +24,7 @@ import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.io.StringWriter;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
@@ -163,6 +164,15 @@ public final class XmlFile {
|
||||
return new InputStreamReader(new FileInputStream(file),sniffEncoding());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the XML file read as a string.
|
||||
*/
|
||||
public String asString() throws IOException {
|
||||
StringWriter w = new StringWriter();
|
||||
writeRawTo(w);
|
||||
return w.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw XML to the given {@link Writer}.
|
||||
* Writer will not be closed by the implementation.
|
||||
|
||||
Reference in new issue
Block a user