引用 http://anjun.cc/post/651.html
private byte[] intToByteArray(final int integer) throws IOException {
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
// DataOutputStream dos = new DataOutputStream(bos);
// dos.writeInt(integer);
// dos.flush();
// return bos.toByteArray();
byte[] result = new byte[4];
result[0] = (byte) (integer >> 24 & 0xff);
result[1] = (byte) (integer >> 16 & 0xff);
result[2] = (byte) (integer >> 8 & 0xff);
result[3] = (byte) (integer & 0xff);
return result;
}
时间: 2024-11-08 20:58:02