我是靠谱客的博主 激动机器猫,这篇文章主要介绍Android笔记--int、String、图片转化为byte[]再转化为int、String、图片和将图片保存SQLite数据库,现在分享给大家,希望可以做个参考。

整理,以前很想弄清楚的字节转换。

1、int转成byte[]

方法:public static byte[] intToBytes(int id) {
byte[] arr = new byte[4];
arr[0] = (byte) ((id >> 0 * 8) & 0xFF);
arr[1] = (byte) ((id >> 1 * 8) & 0xFF);
arr[2] = (byte) ((id >> 2 * 8) & 0xFF);
arr[3] = (byte) ((id >> 3 * 8) & 0xFF);
return arr;
}

使用:byte[] arr=intToBytes(1234);

byte[]转成int

方法:public static int BytesToint(byte[] arr) {
   int rs0=(int)((arr[0]&0xff)<<0*8);
 

最后

以上就是激动机器猫最近收集整理的关于Android笔记--int、String、图片转化为byte[]再转化为int、String、图片和将图片保存SQLite数据库的全部内容,更多相关Android笔记--int、String、图片转化为byte[]再转化为int、String、图片和将图片保存SQLite数据库内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(51)

评论列表共有 0 条评论

立即
投稿
返回
顶部