diff --git a/core/src/main/java/hudson/model/LargeText.java b/core/src/main/java/hudson/model/LargeText.java index cb94c70137ce7fcb6db3cd4208b2e1804ec11e68..8a6380101720af6fb93e4466d7e0caba5a4f7246 100644 --- a/core/src/main/java/hudson/model/LargeText.java +++ b/core/src/main/java/hudson/model/LargeText.java @@ -15,6 +15,8 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.RandomAccessFile; import java.io.Writer; +import java.io.Reader; +import java.io.InputStreamReader; /** * Represents a large text data. @@ -79,6 +81,29 @@ public class LargeText { return completed; } + /** + * Returns {@link Reader} for reading the raw bytes. + */ + public Reader readAll() throws IOException { + return new InputStreamReader(new InputStream() { + final Session session = source.open(); + public int read() throws IOException { + byte[] buf = new byte[1]; + int n = session.read(buf); + if(n==1) return buf[0]; + else return -1; // EOF + } + + public int read(byte[] buf, int off, int len) throws IOException { + return session.read(buf,off,len); + } + + public void close() throws IOException { + session.close(); + } + }); + } + /** * Writes the tail portion of the file to the {@link Writer}. *