Class ByteArrayOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- com.github.shyiko.mysql.binlog.io.ByteArrayOutputStream
-
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
public class ByteArrayOutputStream extends OutputStream
- Author:
- Stanley Shyiko
-
-
Constructor Summary
Constructors Constructor Description ByteArrayOutputStream()
ByteArrayOutputStream(OutputStream outputStream)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
flush()
byte[]
toByteArray()
void
write(byte[] bytes)
void
write(int b)
void
writeInteger(int value, int length)
Write int in little-endian format.void
writeLong(long value, int length)
Write long in little-endian format.void
writeString(String value)
void
writeZeroTerminatedString(String value)
-
Methods inherited from class java.io.OutputStream
nullOutputStream, write
-
-
-
-
Constructor Detail
-
ByteArrayOutputStream
public ByteArrayOutputStream()
-
ByteArrayOutputStream
public ByteArrayOutputStream(OutputStream outputStream)
-
-
Method Detail
-
writeInteger
public void writeInteger(int value, int length) throws IOException
Write int in little-endian format.- Parameters:
value
- integer to writelength
- length in bytes of the integer- Throws:
IOException
- on underlying stream error
-
writeLong
public void writeLong(long value, int length) throws IOException
Write long in little-endian format.- Parameters:
value
- long to writelength
- length in bytes of the long- Throws:
IOException
- on underlying stream error
-
writeString
public void writeString(String value) throws IOException
- Throws:
IOException
-
writeZeroTerminatedString
public void writeZeroTerminatedString(String value) throws IOException
- Parameters:
value
- string to write- Throws:
IOException
- on underlying stream error- See Also:
ByteArrayInputStream.readZeroTerminatedString()
-
write
public void write(int b) throws IOException
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
write
public void write(byte[] bytes) throws IOException
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
toByteArray
public byte[] toByteArray()
-
flush
public void flush() throws IOException
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
-