java中short,int转换成byte数组及byte数组转换成short,int
摘要:
private static byte[] shortToByteArray(short s) { byte[] shortBuf = new byte[2]; for(int i=0;i<2;i++) { int offset = (shortBuf.length - 1 -i)*8; shortBuf[i] = (byte)((s>>>offset)&0xff); } return shortBuf; } public static final int byteArrayToShort(byte [] b) { return (b[0] << 8 阅读全文
posted @ 2012-01-09 23:10
端小六
阅读(1622)
评论(0)
推荐(0)