Skip to content

Commit

Permalink
do not write single bytes
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1915953 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Axel Howind committed Feb 22, 2024
1 parent 39a1ced commit e65e666
Showing 1 changed file with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,39 +145,41 @@ int writeEND(int entriesCount, int offset, int length) throws IOException {
* Writes a 16-bit short to the output stream in little-endian byte order.
*/
private void writeShort(int v) throws IOException {
OutputStream out = this.out;
out.write((v >>> 0) & 0xff);
out.write((v >>> 8) & 0xff);
out.write(new byte[]{
(byte) ((v >>> 0) & 0xff),
(byte) ((v >>> 8) & 0xff)
});
written += 2;
}

/**
* Writes a 32-bit int to the output stream in little-endian byte order.
*/
private void writeInt(long v) throws IOException {
OutputStream out = this.out;
out.write((int) ((v >>> 0) & 0xff));
out.write((int) ((v >>> 8) & 0xff));
out.write((int) ((v >>> 16) & 0xff));
out.write((int) ((v >>> 24) & 0xff));
out.write(new byte[]{
(byte) ((v >>> 0) & 0xff),
(byte) ((v >>> 8) & 0xff),
(byte) ((v >>> 16) & 0xff),
(byte) ((v >>> 24) & 0xff)
});
written += 4;
}

/**
* Writes a 64-bit int to the output stream in little-endian byte order.
*/
private void writeLong(long v) throws IOException {
OutputStream out = this.out;
out.write((int) ((v >>> 0) & 0xff));
out.write((int) ((v >>> 8) & 0xff));
out.write((int) ((v >>> 16) & 0xff));
out.write((int) ((v >>> 24) & 0xff));
out.write((int) ((v >>> 32) & 0xff));
out.write((int) ((v >>> 40) & 0xff));
out.write((int) ((v >>> 48) & 0xff));
out.write((int) ((v >>> 56) & 0xff));
out.write(new byte[]{
(byte) ((v >>> 0) & 0xff),
(byte) ((v >>> 8) & 0xff),
(byte) ((v >>> 16) & 0xff),
(byte) ((v >>> 24) & 0xff),
(byte) ((v >>> 32) & 0xff),
(byte) ((v >>> 40) & 0xff),
(byte) ((v >>> 48) & 0xff),
(byte) ((v >>> 56) & 0xff)
});
written += 8;
}

}

0 comments on commit e65e666

Please sign in to comment.