public void write(byte[] b) throws IOException {
<BUG>if (!outputLocked) {
onWrite();</BUG>
this.totalLength += b.length;
if (inMemory && totalLength > threshold && currentStream instanceof ByteArrayOutputStream) {
<BUG>createFileOutputStream();
}</BUG>
currentStream.write(b);
<BUG>}
}</BUG>
public void write(int b) throws IOException {

public void write(byte[] b) throws IOException {
this.totalLength += b.length;
if (inMemory && totalLength > threshold && currentStream instanceof ByteArrayOutputStream) {
pageToFileStream();
}
currentStream.write(b);
flush();
}
