@Test public void testWriteLong() throws IOException { final long value = 256L; final ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); final LittleEndianDataOutputStream littleEndianOut = new LittleEndianDataOutputStream(byteOut); littleEndianOut.writeLong(value); littleEndianOut.close(); final byte[] expected = ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN).putLong(value).array(); assertTrue(Arrays.equals(expected, byteOut.toByteArray())); }
@Override public void writeLong(long v) throws IOException { out.write((int) (0xFF & v)); out.write((int) (0xFF & (v >> 8))); out.write((int) (0xFF & (v >> 16))); out.write((int) (0xFF & (v >> 24))); out.write((int) (0xFF & (v >> 32))); out.write((int) (0xFF & (v >> 40))); out.write((int) (0xFF & (v >> 48))); out.write((int) (0xFF & (v >> 56))); }
LittleEndianDataOutputStream extends FilterOutputStream implements DataOutput { @Override public void writeLong(long v) throws IOException { out.write((int) (0xFF & v)); out.write((int) (0xFF & (v >> 8))); out.write((int) (0xFF & (v >> 16))); out.write((int) (0xFF & (v >> 24))); out.write((int) (0xFF & (v >> 32))); out.write((int) (0xFF & (v >> 40))); out.write((int) (0xFF & (v >> 48))); out.write((int) (0xFF & (v >> 56))); } }
LittleEndianDataOutputStream extends FilterOutputStream implements DataOutput { @Override public void writeLong(long v) throws IOException { out.write((int) (0xFF & v)); out.write((int) (0xFF & (v >> 8))); out.write((int) (0xFF & (v >> 16))); out.write((int) (0xFF & (v >> 24))); out.write((int) (0xFF & (v >> 32))); out.write((int) (0xFF & (v >> 40))); out.write((int) (0xFF & (v >> 48))); out.write((int) (0xFF & (v >> 56))); } LittleEndianDataOutputStream(OutputStream out); }
LittleEndianDataOutputStream extends FilterOutputStream implements DataOutput { @Override public void writeLong(long v) throws IOException { out.write((int) (0xFF & v)); out.write((int) (0xFF & (v >> 8))); out.write((int) (0xFF & (v >> 16))); out.write((int) (0xFF & (v >> 24))); out.write((int) (0xFF & (v >> 32))); out.write((int) (0xFF & (v >> 40))); out.write((int) (0xFF & (v >> 48))); out.write((int) (0xFF & (v >> 56))); } LittleEndianDataOutputStream(OutputStream out); @Override void write(byte[] b, int off, int len); @Override void writeBoolean(boolean v); @Override void writeByte(int v); @Override void writeShort(int v); @Override void writeChar(int v); @Override void writeInt(int v); @Override void writeLong(long v); @Override void writeFloat(float v); @Override void writeDouble(double v); @Override void writeBytes(String s); @Override void writeChars(String s); @Override void writeUTF(String str); @Override void close(); }
LittleEndianDataOutputStream extends FilterOutputStream implements DataOutput { @Override public void writeLong(long v) throws IOException { out.write((int) (0xFF & v)); out.write((int) (0xFF & (v >> 8))); out.write((int) (0xFF & (v >> 16))); out.write((int) (0xFF & (v >> 24))); out.write((int) (0xFF & (v >> 32))); out.write((int) (0xFF & (v >> 40))); out.write((int) (0xFF & (v >> 48))); out.write((int) (0xFF & (v >> 56))); } LittleEndianDataOutputStream(OutputStream out); @Override void write(byte[] b, int off, int len); @Override void writeBoolean(boolean v); @Override void writeByte(int v); @Override void writeShort(int v); @Override void writeChar(int v); @Override void writeInt(int v); @Override void writeLong(long v); @Override void writeFloat(float v); @Override void writeDouble(double v); @Override void writeBytes(String s); @Override void writeChars(String s); @Override void writeUTF(String str); @Override void close();  }