Package org.apache.parquet.bytes
Class LittleEndianDataOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.apache.parquet.bytes.LittleEndianDataOutputStream
-
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
public class LittleEndianDataOutputStream extends OutputStream
Based on DataOutputStream but in little endian and without the String/char methods
-
-
Constructor Summary
Constructors Constructor Description LittleEndianDataOutputStream(OutputStream out)
Creates a new data output stream to write data to the specified underlying output stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
flush()
Flushes this data output stream.void
write(byte[] b, int off, int len)
Writeslen
bytes from the specified byte array starting at offsetoff
to the underlying output stream.void
write(int b)
Writes the specified byte (the low eight bits of the argumentb
) to the underlying output stream.void
writeBoolean(boolean v)
Writes aboolean
to the underlying output stream as a 1-byte value.void
writeByte(int v)
Writes out abyte
to the underlying output stream as a 1-byte value.void
writeDouble(double v)
Converts the double argument to along
using thedoubleToLongBits
method in classDouble
, and then writes thatlong
value to the underlying output stream as an 8-byte quantity, low byte first.void
writeFloat(float v)
Converts the float argument to anint
using thefloatToIntBits
method in classFloat
, and then writes thatint
value to the underlying output stream as a 4-byte quantity, low byte first.void
writeInt(int v)
Writes anint
to the underlying output stream as four bytes, low byte first.void
writeLong(long v)
Writes along
to the underlying output stream as eight bytes, low byte first.void
writeShort(int v)
Writes ashort
to the underlying output stream as two bytes, low byte first.-
Methods inherited from class java.io.OutputStream
nullOutputStream, write
-
-
-
-
Constructor Detail
-
LittleEndianDataOutputStream
public LittleEndianDataOutputStream(OutputStream out)
Creates a new data output stream to write data to the specified underlying output stream. The counterwritten
is set to zero.- Parameters:
out
- the underlying output stream, to be saved for later use.- See Also:
FilterOutputStream.out
-
-
Method Detail
-
write
public void write(int b) throws IOException
Writes the specified byte (the low eight bits of the argumentb
) to the underlying output stream. If no exception is thrown, the counterwritten
is incremented by1
.Implements the
write
method ofOutputStream
.- Specified by:
write
in classOutputStream
- Parameters:
b
- thebyte
to be written.- Throws:
IOException
- if an I/O error occurs.- See Also:
FilterOutputStream.out
-
write
public void write(byte[] b, int off, int len) throws IOException
Writeslen
bytes from the specified byte array starting at offsetoff
to the underlying output stream. If no exception is thrown, the counterwritten
is incremented bylen
.- Overrides:
write
in classOutputStream
- Parameters:
b
- the data.off
- the start offset in the data.len
- the number of bytes to write.- Throws:
IOException
- if an I/O error occurs.- See Also:
FilterOutputStream.out
-
flush
public void flush() throws IOException
Flushes this data output stream. This forces any buffered output bytes to be written out to the stream.The
flush
method ofDataOutputStream
calls theflush
method of its underlying output stream.- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
- if an I/O error occurs.- See Also:
FilterOutputStream.out
,OutputStream.flush()
-
writeBoolean
public final void writeBoolean(boolean v) throws IOException
Writes aboolean
to the underlying output stream as a 1-byte value. The valuetrue
is written out as the value(byte)1
; the valuefalse
is written out as the value(byte)0
. If no exception is thrown, the counterwritten
is incremented by1
.- Parameters:
v
- aboolean
value to be written.- Throws:
IOException
- if an I/O error occurs.- See Also:
FilterOutputStream.out
-
writeByte
public final void writeByte(int v) throws IOException
Writes out abyte
to the underlying output stream as a 1-byte value. If no exception is thrown, the counterwritten
is incremented by1
.- Parameters:
v
- abyte
value to be written.- Throws:
IOException
- if an I/O error occurs.- See Also:
FilterOutputStream.out
-
writeShort
public final void writeShort(int v) throws IOException
Writes ashort
to the underlying output stream as two bytes, low byte first. If no exception is thrown, the counterwritten
is incremented by2
.- Parameters:
v
- ashort
to be written.- Throws:
IOException
- if an I/O error occurs.- See Also:
FilterOutputStream.out
-
writeInt
public final void writeInt(int v) throws IOException
Writes anint
to the underlying output stream as four bytes, low byte first. If no exception is thrown, the counterwritten
is incremented by4
.- Parameters:
v
- anint
to be written.- Throws:
IOException
- if an I/O error occurs.- See Also:
FilterOutputStream.out
-
writeLong
public final void writeLong(long v) throws IOException
Writes along
to the underlying output stream as eight bytes, low byte first. In no exception is thrown, the counterwritten
is incremented by8
.- Parameters:
v
- along
to be written.- Throws:
IOException
- if an I/O error occurs.- See Also:
FilterOutputStream.out
-
writeFloat
public final void writeFloat(float v) throws IOException
Converts the float argument to anint
using thefloatToIntBits
method in classFloat
, and then writes thatint
value to the underlying output stream as a 4-byte quantity, low byte first. If no exception is thrown, the counterwritten
is incremented by4
.- Parameters:
v
- afloat
value to be written.- Throws:
IOException
- if an I/O error occurs.- See Also:
FilterOutputStream.out
,Float.floatToIntBits(float)
-
writeDouble
public final void writeDouble(double v) throws IOException
Converts the double argument to along
using thedoubleToLongBits
method in classDouble
, and then writes thatlong
value to the underlying output stream as an 8-byte quantity, low byte first. If no exception is thrown, the counterwritten
is incremented by8
.- Parameters:
v
- adouble
value to be written.- Throws:
IOException
- if an I/O error occurs.- See Also:
FilterOutputStream.out
,Double.doubleToLongBits(double)
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
-
-