Java Utililty Methods OutputStream Write Int

List of utility methods to do OutputStream Write Int

Description

The list of methods to do OutputStream Write Int are organized into topic(s).

Method

voidwriteInt(OutputStream buffer, int value)
write Int
buffer.write(value & BYTE_MASK);
buffer.write((value >>> BYTE1) & BYTE_MASK);
buffer.write((value >>> BYTE2) & BYTE_MASK);
buffer.write((value >>> BYTE3) & BYTE_MASK);
intwriteInt(OutputStream dest, int val)
write Int
byte[] out = new byte[4];
for (int i = 0; i < 4; i++) {
    out[i] = (byte) ((val >> i * 8) & 0xff);
dest.write(out);
return 4;
voidwriteInt(OutputStream file, int value)
The "writeInt" function of java writes in BigEndian mode but we need LittleEndian so i made a custom function for that
int ch1 = (byte) (value >>> 24);
int ch2 = (byte) (value >>> 16);
int ch3 = (byte) (value >>> 8);
int ch4 = (byte) value;
file.write(ch4);
file.write(ch3);
file.write(ch2);
file.write(ch1);
...
voidwriteInt(OutputStream os, int n)
write Int
os.write((n >> 0) & 0xff);
os.write((n >> 8) & 0xff);
os.write((n >> 16) & 0xff);
os.write((n >> 24) & 0xff);
voidwriteInt(OutputStream os, int v)
write Int
os.write(v >> 24);
os.write(v >> 16);
os.write(v >> 8);
os.write(v);
voidwriteInt(OutputStream os, int val)
write Int
os.write(val >>> 24);
os.write(val >>> 16);
os.write(val >>> 8);
os.write(val);
voidwriteInt(OutputStream os, int value)
write Int
byte[] buffer = new byte[4];
buffer[0] = (byte) (value >> 24);
buffer[1] = (byte) (value >> 16);
buffer[2] = (byte) (value >> 8);
buffer[3] = (byte) value;
try {
    os.write(buffer);
} catch (IOException e) {
...
voidwriteInt(OutputStream os, int value)
write Int
os.write(new byte[] { (byte) value, (byte) (value >>> 8), (byte) (value >>> 16), (byte) (value >>> 24) });
voidwriteInt(OutputStream os, int value)
write Int
os.write(value >> 24);
os.write(value >> 16);
os.write(value >> 8);
os.write(value >> 0);
voidwriteInt(OutputStream os, long v)
write Int
os.write((int) (v & 0xff));
os.write((int) ((v >>> 8) & 0xff));
os.write((int) ((v >>> 16) & 0xff));
os.write((int) ((v >>> 24) & 0xff));