码迷,mamicode.com
首页 > 编程语言 > 详细

java byte转无符号int

时间:2014-06-11 09:47:13      阅读:395      评论:0      收藏:0      [点我收藏+]

标签:style   class   blog   code   java   http   

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

java byte转无符号int

标签:style   class   blog   code   java   http   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!