美文网首页
andorid 日常(二十一)

andorid 日常(二十一)

作者: ncd | 来源:发表于2017-02-06 11:57 被阅读19次
    public static byte[] toByteArray(short[] src) {
            int count = src.length;
            byte[] dest = new byte[count << 1];
            for (int i = 0; i < count; i++) {
                    dest[i * 2] = (byte) (src[i]);
                    dest[i * 2 + 1] = (byte) (src[i] >> 8);
            }
            return dest;
        }
    public short[] toShortArray(byte[] src) {
            int count = src.length >> 1;
            short[] dest = new short[count];
            for (int i = 0; i < count; i++) {
                    dest[i] = (short) ((src[i * 2] & 0xff) | ((src[2 * i + 1] & 0xff) << 8));
            }
            return dest;
    }
    

    相关文章

      网友评论

          本文标题:andorid 日常(二十一)

          本文链接:https://www.haomeiwen.com/subject/sjwyittx.html