java byte转无符号int

时间:2014-06-11 09:44:20   收藏:0   阅读:457
bubuko.com,布布扣
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));
    }
}
bubuko.com,布布扣

 

java byte转无符号int,布布扣,bubuko.com

原文:http://www.cnblogs.com/zhangpengshou/p/3773097.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!