Package org.apache.iotdb.tsfile.utils
Class PublicBAOS
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.ByteArrayOutputStream
-
- org.apache.iotdb.tsfile.utils.PublicBAOS
-
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
public class PublicBAOS extends ByteArrayOutputStream
A subclass extendingByteArrayOutputStream. It's used to return the byte array directly. Note that the size of byte array is large than actual size of valid contents, thus it's used cooperating withsize()orcapacity = size
-
-
Field Summary
-
Fields inherited from class java.io.ByteArrayOutputStream
buf, count
-
-
Constructor Summary
Constructors Constructor Description PublicBAOS()PublicBAOS(int size)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]getBuf()get current all bytes datavoidreset()It's not a thread-safe method.intsize()The synchronized keyword in this function is intentionally removed.voidtruncate(int size)voidwriteTo(OutputStream out)It's not a thread-safe method.-
Methods inherited from class java.io.ByteArrayOutputStream
close, toByteArray, toString, toString, toString, write, write
-
Methods inherited from class java.io.OutputStream
flush, write
-
-
-
-
Method Detail
-
getBuf
public byte[] getBuf()
get current all bytes data- Returns:
- all bytes data
-
writeTo
public void writeTo(OutputStream out) throws IOException
It's not a thread-safe method. Override the super class's implementation. Remove the synchronized key word, to save the synchronization overhead.Writes the complete contents of this byte array output stream to the specified output stream argument, as if by calling the output stream's write method using
out.write(buf, 0, count).- Overrides:
writeToin classByteArrayOutputStream- Parameters:
out- the output stream to which to write the data.- Throws:
IOException- if an I/O error occurs.
-
reset
public void reset()
It's not a thread-safe method. Override the super class's implementation. Remove the synchronized key word, to save the synchronization overhead.Resets the
countfield of this byte array output stream to zero, so that all currently accumulated output in the output stream is discarded. The output stream can be used again, reusing the already allocated buffer space.- Overrides:
resetin classByteArrayOutputStream
-
size
public int size()
The synchronized keyword in this function is intentionally removed. For details, see https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=173085039- Overrides:
sizein classByteArrayOutputStream
-
truncate
public void truncate(int size)
-
-