提交 c55e36ee 编写于 作者: K kohsuke

addd a method to read all data through Reader.


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