UnsyncBufferedOutputStreampublic class UnsyncBufferedOutputStream extends OutputStream A class that buffers writte without synchronize its methods |
Fields Summary |
---|
final OutputStream | out | static final int | size | final byte[] | buf | int | pointer |
Constructors Summary |
---|
public UnsyncBufferedOutputStream(OutputStream out)Creates a buffered output stream without synchronization
this.out=out;
|
Methods Summary |
---|
public void | close()
flush();
| public void | flush()
flushBuffer();
out.flush();
| private final void | flushBuffer()
if (pointer>0)
out.write(buf,0,pointer);
pointer=0;
| public void | write(byte[] arg0)
write(arg0,0,arg0.length);
| public void | write(byte[] arg0, int arg1, int len)
int newLen=pointer+len;
if (newLen> size) {
flushBuffer();
if (len>size) {
out.write(arg0,arg1,len);
return;
}
newLen=len;
}
System.arraycopy(arg0,arg1,buf,pointer,len);
pointer=newLen;
| public void | write(int arg0)
if (pointer>= size) {
flushBuffer();
}
buf[pointer++]=(byte)arg0;
|
|