Java 如何将int数组转换为字节数组
如何将int[]转换为byte[] 或者更改代码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
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);
}
}