public class WriteBuffer extends OutputStream
| Modifier | Constructor and Description |
|---|---|
protected |
WriteBuffer(org.aoju.bus.core.io.segment.BufferPage bufferPage,
org.aoju.bus.socket.origin.Function<WriteBuffer,Void> flushFunction,
int writeQueueSize) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
flush() |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b)
按照
OutputStream.write(int)规范:要写入的字节是参数 b 的八个低位 b 的 24 个高位将被忽略
而使用该接口时容易传入非byte范围内的数据,接口定义与实际使用出现歧义的可能性较大,故建议废弃该方法,选用writeByte(byte) |
void |
writeAndFlush(byte[] b)
写入内容并刷新缓冲区 在
Message.process(AioSession, Object)执行的write操作可无需调用该方法,业务执行完毕后框架本身会自动触发flush
调用该方法后数据会及时的输出到对端,如果再循环体中通过该方法往某个通道中写入数据将无法获得最佳性能表现, |
void |
writeAndFlush(byte[] b,
int off,
int len) |
void |
writeByte(byte b) |
void |
writeInt(int v) |
void |
writeShort(short v) |
writeprotected WriteBuffer(org.aoju.bus.core.io.segment.BufferPage bufferPage,
org.aoju.bus.socket.origin.Function<WriteBuffer,Void> flushFunction,
int writeQueueSize)
public void write(int b)
throws IOException
OutputStream.write(int)规范:要写入的字节是参数 b 的八个低位 b 的 24 个高位将被忽略
而使用该接口时容易传入非byte范围内的数据,接口定义与实际使用出现歧义的可能性较大,故建议废弃该方法,选用writeByte(byte)write in class OutputStreamb - byteIOException - 如果发生 I/O 错误public void writeShort(short v)
throws IOException
IOExceptionpublic void writeByte(byte b)
public void writeInt(int v)
throws IOException
IOExceptionpublic void write(byte[] b,
int off,
int len)
throws IOException
write in class OutputStreamIOExceptionpublic void writeAndFlush(byte[] b)
throws IOException
Message.process(AioSession, Object)执行的write操作可无需调用该方法,业务执行完毕后框架本身会自动触发flush
调用该方法后数据会及时的输出到对端,如果再循环体中通过该方法往某个通道中写入数据将无法获得最佳性能表现,b - 待输出数据IOException - 如果发生 I/O 错误public void writeAndFlush(byte[] b,
int off,
int len)
throws IOException
b - 待输出数据off - b的起始位点len - 从b中输出的数据长度IOException - 如果发生 I/O 错误writeAndFlush(byte[])public void flush()
flush in interface Flushableflush in class OutputStreampublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamIOExceptionCopyright © 2019. All rights reserved.