Decoder { public static int readInt(byte[] dest, ByteBuffer bb, InputStream is) throws IOException { readNumberOfBytes(dest, bb, is); return ((dest[0] & 0xff) << 24) | ((dest[1] & 0xff) << 16) | ((dest[2] & 0xff) << 8) | (dest[3] & 0xff); }  static Pair<List<String>, List<double[]>> decodeBinaryEmbeddingVectors(InputStream is); static Pair<List<String>, List<double[]>> decodeBinaryEmbeddingVectors(InputStream is, int bufferSize); static void mergeEmbeddingFiles(List<InputStream> inputStreams, OutputStream os, boolean groupByText); static double readDouble(byte[] dest, ByteBuffer bb, InputStream is); static int readInt(byte[] dest, ByteBuffer bb, InputStream is); static void readNumberOfBytes(byte[] dest, ByteBuffer bb, InputStream is);  }
@Test public void testReadInt() throws IOException { ByteBuffer bb = ByteBuffer.allocate(Integer.BYTES); bb.putInt(12345678); bb.position(0); final ByteArrayInputStream bais = new ByteArrayInputStream(bb.array()); final int d = Decoder.readInt(new byte[Integer.BYTES], bb, bais); assertThat(d).isEqualTo(12345678); }