日期:2014-05-20  浏览次数:20677 次

java writeint() ?
writeint()把288 转为什么byte[]?

------解决方案--------------------
楼主把问题描述清楚一点?
------解决方案--------------------

public static byte[] intArrayToByteArray(int[] array) {
byte[] b = new byte[array.length * 4];
for (int i = 0; i < array.length; i++) {
ByteArrayOutputStream boutput = new ByteArrayOutputStream();
DataOutputStream doutput = new DataOutputStream(boutput);
try {
doutput.writeInt(array[i]);
} catch (IOException e) {
e.printStackTrace();
}
byte[] temp = boutput.toByteArray();

for (int j = 0; j < temp.length; j++) {
b[i * 4 + j] = temp[j];
}

}

return b;
}