public class ByteArrayOutputStream extends OutputStream
ByteArrayOutputStream替换方案, 执行toByteArray()
方法时返回的是只读的内部字节数组, 避免了没有必要的字节复制. 本代码移植自IBM developer works文章:
| 构造器和说明 |
|---|
ByteArrayOutputStream() |
ByteArrayOutputStream(int initialBufferSize) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
close() |
void |
reset() |
ByteArray |
toByteArray() |
InputStream |
toInputStream() |
void |
write(byte[] data,
int offset,
int length) |
void |
write(int datum) |
void |
writeTo(OutputStream out) |
flush, writepublic ByteArrayOutputStream()
public ByteArrayOutputStream(int initialBufferSize)
public void write(int datum)
throws IOException
write 在类中 OutputStreamIOExceptionpublic void write(byte[] data,
int offset,
int length)
throws IOException
write 在类中 OutputStreamIOExceptionpublic void close()
close 在接口中 Closeableclose 在接口中 AutoCloseableclose 在类中 OutputStreampublic void writeTo(OutputStream out) throws IOException
IOExceptionpublic ByteArray toByteArray()
public InputStream toInputStream()
public void reset()
throws IOException
IOExceptionCopyright © 2006–2018 TinyGroup. All rights reserved.