fragment_array[i] = fragment[i];  fragment_array = ByteBuffer.wrap(fragment_array).order(ByteOrder.LITTLE_ENDIAN).array(); for(i=0; i<fragment.length; i++) datagram[i+shift] = fragment_array[i];
fragment_array[j--] = fragment[i]; ArrayManipulator.copyArrayAtEnd(datagram, fragment_array, shift);
    public static byte[] createImageDatagram(int file_index, int image_number, 					     int image_size, int offset, byte [] fragment)	throws InvalidParameterException    {	//creation	if(fragment.length>1006)throw new InvalidParameterException("fragment length too important");	//1006+18 = 1024 = datagram max length	byte [] datagram = UDPDatagramHeader.createUDPDatagramHeader(file_index, Opcode.IMAGE, 18+fragment.length);	byte [] image_number_array = int2ByteArray(image_number);	byte [] image_size_array = int2ByteArray(image_size);	byte [] offset_array = int2ByteArray(offset);	int i; int shift = UDPDatagramHeader.getHeaderSize();	//initialisation	for(i=0; i<4; i++)	    datagram[i+shift] = image_number_array[i];	shift+=i;	for(i=0; i<4; i++)	    datagram[i+shift] = image_size_array[i];	shift+=i;	for(i=0; i<4; i++)	    datagram[i+shift] = offset_array[i];	shift+=i;	//copy the fragment in a temporary array to avoid messing up 'fragment'...	byte [] fragment_array = new byte[fragment.length];	for(i=0; i<fragment.length; i++)	    fragment_array[i] = fragment[i];	//...then order in the little-endian way.	fragment_array = ByteBuffer.wrap(fragment_array).order(ByteOrder.LITTLE_ENDIAN).array();	for(i=0; i<fragment.length; i++)	    datagram[i+shift] = fragment_array[i];	return datagram;    }