[Android] short array to byte array

public byte[] shortArray2byteArray(short[] shortArray) {
    int shortArraySize = shortArray.length;
    byte[] byteArray = new byte[shortArraySize * 2];
    for (int i = 0; i < shortArraySize ; i++) {
        byteArray [i * 2] = (byte) (shortArray[i] & 0x00FF);
        byteArray [(i * 2) + 1] = (byte) (shortArray[i] >> 8);
    }
    return byteArray ;
}

Posted by incree

2014/04/28 05:07 2014/04/28 05:07
, , ,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/326

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다


Notices

Archives

Authors

  1. incree

Recent Trackbacks

Calendar

«   2018/11   »
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30  

Site Stats

Total hits:
497750
Today:
27
Yesterday:
263