public class ByteArrayOutputStream extends OutputStream
ByteArrayOutputStream
替换方案, 执行toByteArray()
方法时返回的是只读的内部字节数组, 避免了没有必要的字节复制. 本代码移植自IBM developer works文章:
Constructor and Description |
---|
ByteArrayOutputStream() |
ByteArrayOutputStream(int initialBufferSize) |
Modifier and Type | Method and Description |
---|---|
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, write
public ByteArrayOutputStream()
public ByteArrayOutputStream(int initialBufferSize)
public void write(int datum) throws IOException
write
in class OutputStream
IOException
public void write(byte[] data, int offset, int length) throws IOException
write
in class OutputStream
IOException
public void close()
close
in interface Closeable
close
in interface AutoCloseable
close
in class OutputStream
public void writeTo(OutputStream out) throws IOException
IOException
public ByteArray toByteArray()
public InputStream toInputStream()
public void reset() throws IOException
IOException
Copyright © 2006–2018 TinyGroup. All rights reserved.