天天看點

java byte轉無符号int

import java.io.ByteArrayInputStream;     public class Test{         public static void main(String[] args) {             byte[] bytes =  new byte[]{(byte)-42};             ByteArrayInputStream in = new ByteArrayInputStream(bytes);             int result = in.read();             System.out.println("無符号數: \t"+result);             System.out.println("2進制bit位: \t"+Integer.toBinaryString(result));         }     }