public class BytesOutputStream extends ByteArrayOutputStream implements OutputStreamNio
| 限定符和类型 | 字段和说明 |
|---|---|
static byte[] |
_emptyBytes
空节数组
|
buf, count| 构造器和说明 |
|---|
BytesOutputStream() |
BytesOutputStream(InputStream in)
由输入流创建
|
BytesOutputStream(int size) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
cancel()
取消且关闭
|
byte[] |
detach()
分离缓冲区内部数据
|
InputStream |
detachStream()
分离缓冲区数据转为输入流
|
protected void |
ensureWritableBytes(int minSize)
确保还有可写入的空间
|
Bytes |
getBytes() |
void |
setSize(int length)
重置最后写入位置
|
static int |
transfer(ByteBuffer buffer,
OutputStream out,
int limit)
把ByteBuffer的内容传送到输出流,完成后不会关闭输出流
|
static int |
transfer(InputStream in,
OutputStream out,
int limit)
把输入流的内容传送到输出流,完成后不会关闭它们
|
int |
write(ByteBuffer src)
写入
|
int |
write(InputStream src)
写入
|
close, reset, size, toByteArray, toString, toString, toString, write, write, writeToflush, writeclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitclose, writepublic BytesOutputStream()
public BytesOutputStream(int size)
public BytesOutputStream(InputStream in) throws IOException
in - 内容输入流IOException - IO异常时抛出public byte[] detach()
public Bytes getBytes()
public InputStream detachStream() throws IOException
IOExceptionpublic void setSize(int length)
throws IOException
length - 位置IOException - IO异常时抛出public int write(InputStream src) throws IOException
OutputStreamNiowrite 在接口中 OutputStreamNiosrc - 要写入的输入流IOException - IO异常时抛出public int write(ByteBuffer src) throws IOException
OutputStreamNiowrite 在接口中 OutputStreamNiosrc - 要写入的数据IOException - IO异常时抛出public void cancel()
throws IOException
OutputStreamNiocancel 在接口中 OutputStreamNioIOException - IO异常时抛出protected void ensureWritableBytes(int minSize)
minSize - 至少可写空间(字节数)public static int transfer(InputStream in, OutputStream out, int limit) throws IOException
in - 输入流out - 输出流limit - 若>0则限制读取的字节数IOException - IO异常时抛出public static int transfer(ByteBuffer buffer, OutputStream out, int limit) throws IOException
buffer - 字节缓冲区的内容out - 输出流limit - 若>0则限制读取的字节数IOException - IO异常时抛出Copyright © 2021. All rights reserved.