首页 > 编程语言 > 详细

java int to byte array

时间:2015-07-19 17:47:13      阅读:132      评论:0      收藏:0      [点我收藏+]

引用 http://anjun.cc/post/651.html  

private byte[] intToByteArray(final int integer) throws IOException {
//        ByteArrayOutputStream bos = new ByteArrayOutputStream();
//        DataOutputStream dos = new DataOutputStream(bos);
//        dos.writeInt(integer);
//        dos.flush();
//        return bos.toByteArray();
        byte[] result = new byte[4];
      
        result[0] = (byte) (integer >> 24 & 0xff);
        result[1] = (byte) (integer >> 16 & 0xff);
        result[2] = (byte) (integer >> 8 & 0xff);
        result[3] = (byte) (integer & 0xff);
        
        return result;
    }

 

java int to byte array

原文:http://www.cnblogs.com/anjuncc/p/4658873.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!