Here you can find the source of toBytesWithLengthLong(byte[] buffer, int pos, byte[] bytes)
public static int toBytesWithLengthLong(byte[] buffer, int pos, byte[] bytes)
//package com.java2s; //License from project: Apache License public class Main { public static int toBytesWithLengthLong(byte[] buffer, int pos, byte[] bytes) { buffer[pos] = (byte) (bytes.length >> 24); buffer[pos + 1] = (byte) ((bytes.length >> 16) & 255); buffer[pos + 2] = (byte) ((bytes.length >> 8) & 255); buffer[pos + 3] = (byte) (bytes.length & 255); System.arraycopy(bytes, 0, buffer, pos + 4, bytes.length); return pos + bytes.length + 4; }//from w w w .j a v a 2 s.c o m }