Convertir un tableau de int en un tableau d’octet

Author:

 java, table
{filelink=4679}


public class Tab_Conversion2 {

  /*
   * La fonction reçoit un tableau
   * de int en paramètre et retourne
   * un tableau d'octet comme valeur
   */
  public static byte[] int2byte(int[]int_Tab)
  {

    int intTab_Length = int_Tab.length;
    byte[]byte_Tab = new byte[intTab_Length << 2];

    for (int i=0; i>> 0) & 0xff);
        byte_Tab[j++] = (byte) ((x >>> 8) & 0xff);
        byte_Tab[j++] = (byte) ((x >>> 16) & 0xff);
        byte_Tab[j++] = (byte) ((x >>> 24) & 0xff);
    	}
    return byte_Tab;
	}
}

Leave a Reply

Your email address will not be published. Required fields are marked *