Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何将int数组转换为字节数组_Java_Android - Fatal编程技术网

Java 如何将int数组转换为字节数组

Java 如何将int数组转换为字节数组,java,android,Java,Android,如何将int[]转换为byte[] 或者更改代码 IntBuffer buffer=IntBuffer.wrap(b); int[] = buffer.array(); 到字节[] 你能给我一些帮助吗?试试这个 int b[]=new int[(int) (w*h)]; int bt[]=new int[(int) (w*h)]; IntBuffer buff

如何将int[]转换为byte[]

或者更改代码

          IntBuffer buffer=IntBuffer.wrap(b);
          int[] = buffer.array();
到字节[]

你能给我一些帮助吗?

试试这个

                int b[]=new int[(int) (w*h)];
                int bt[]=new int[(int) (w*h)];
                IntBuffer buffer=IntBuffer.wrap(b);
byte[]ba=新字节[bt.length*4];
for(int i=0,k=0;i>(8*j))&0xFF);
}
}  
                int b[]=new int[(int) (w*h)];
                int bt[]=new int[(int) (w*h)];
                IntBuffer buffer=IntBuffer.wrap(b);
byte[] ba= new byte[bt.length * 4];

for(int i = 0, k = 0; i < bt.length; i++) {
     int temp= bt[i];
       for(int j = 0; j < 4; j++, k++) {
         ba[k] = (byte)((temp>> (8 * j)) & 0xFF);
     }
}