java如何将byte[4]数组转换成一个int型数据?
展开全部
byte[] bs = new byte[4];
bs[0] = 1;
bs[1] = 2;
bs[2] = 3;
bs[3] = 4;
int r = 0;
PipedOutputStream pos = new PipedOutputStream();
PipedInputStream pis = new PipedInputStream();
//连接管道
pis.connect(pos);
DataInputStream dis = new DataInputStream(pis);
DataOutputStream dos = new DataOutputStream(pos);
//先写4个字节
dos.write(bs,0,bs.length);
//读取整型
r = dis.readInt();
System.out.println(r);
dis.close();
dos.close();
bs[0] = 1;
bs[1] = 2;
bs[2] = 3;
bs[3] = 4;
int r = 0;
PipedOutputStream pos = new PipedOutputStream();
PipedInputStream pis = new PipedInputStream();
//连接管道
pis.connect(pos);
DataInputStream dis = new DataInputStream(pis);
DataOutputStream dos = new DataOutputStream(pos);
//先写4个字节
dos.write(bs,0,bs.length);
//读取整型
r = dis.readInt();
System.out.println(r);
dis.close();
dos.close();
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询