david's daily developer note

[Java] Char [] to Byte [] 본문

[Develop] Language/JAVA

[Java] Char [] to Byte []

mouse-david 2011. 4. 29. 17:10
728x90
 
char [] bufferIamge  = imageString.toCharArray();
byte [] image  = new byte[bufferIamge.length <<1];

for(int j = 0; j < bufferIamge.length; j++) {
    int bpos = i << 1;
    image[bpos] = (byte) ((bufferIamge[i]&0xFF00)>>8);
    image[bpos + 1] = (byte) (bufferIamge[i]&0x00FF);
}

 

728x90