Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class LittleEndianDataOutputStream extends OutputStream {

private static final Logger LOG = LoggerFactory.getLogger(LittleEndianDataOutputStream.class);
private final OutputStream out;
private byte writeBuffer[] = new byte[8];

/**
* Creates a new data output stream to write data to the specified
Expand Down Expand Up @@ -130,8 +131,9 @@ public final void writeByte(int v) throws IOException {
* @see java.io.FilterOutputStream#out
*/
public final void writeShort(int v) throws IOException {
out.write((v >>> 0) & 0xFF);
out.write((v >>> 8) & 0xFF);
writeBuffer[0] = (byte) (v >>> 0);
writeBuffer[1] = (byte) (v >>> 8);
out.write(writeBuffer, 0, 2);
}

/**
Expand All @@ -144,17 +146,13 @@ public final void writeShort(int v) throws IOException {
* @see java.io.FilterOutputStream#out
*/
public final void writeInt(int v) throws IOException {
// TODO: see note in LittleEndianDataInputStream: maybe faster
// to use Integer.reverseBytes() and then writeInt, or a ByteBuffer
// approach
out.write((v >>> 0) & 0xFF);
out.write((v >>> 8) & 0xFF);
out.write((v >>> 16) & 0xFF);
out.write((v >>> 24) & 0xFF);
writeBuffer[0] = (byte) (v >>> 0);
writeBuffer[1] = (byte) (v >>> 8);
writeBuffer[2] = (byte) (v >>> 16);
writeBuffer[3] = (byte) (v >>> 24);
out.write(writeBuffer, 0, 4);
}

private byte writeBuffer[] = new byte[8];

/**
* Writes a <code>long</code> to the underlying output stream as eight
* bytes, low byte first. In no exception is thrown, the counter
Expand Down