基础题:转换

yanloveyan2004 2005-10-20 11:31:02
[B@1fee6fc 是什么类型,能不能转化为int
...全文
216 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
yanloveyan2004 2005-10-20
  • 打赏
  • 举报
回复
CommPort serialPort = portId.open(portId.getName(), 9600);
InputStream input = serialPort.getInputStream();
byte[] allBytes = new byte[1024];
input.read(allBytes);
FileOutputStream fos=new FileOutputStream("c:\\aaaa.txt");
fos.write(allBytes);
fos.flush();
写入文件有部分是乱码!
yanloveyan2004 2005-10-20
  • 打赏
  • 举报
回复
写入文件变成这个样子呢“0005905889 ”有些没见过的东东
King_Style 2005-10-20
  • 打赏
  • 举报
回复
搞错了,楼主没有写入文件?........
晕呼...
King_Style 2005-10-20
  • 打赏
  • 举报
回复
InputStream 得到的是一个字节数组,你不必关心它是什么,写入文件就OK了
shine333 2005-10-20
  • 打赏
  • 举报
回复
就是一个byte[]

你肯定byte[] b = ...

System.out.println(b)了吧



for (int i = 0; i < b.length; i++) {
System.out.println(b[i]);
}
yanloveyan2004 2005-10-20
  • 打赏
  • 举报
回复
CommPort serialPort = portId.open(portId.getName(), 9600);

/*从端口中读取数据*/

InputStream input = serialPort.getInputStream();
我怎么知道input 具体是什么,我读到byte[]中还是不知道是什么,对方说是16进制数,我怎么才能得到具体数啊!
huangdeji 2005-10-20
  • 打赏
  • 举报
回复
楼上的大哥能不能说得更清楚一些,谢谢
shine333 2005-10-20
  • 打赏
  • 举报
回复
首先这只能是个String,不过这么说可能误导你

其实这是一个B类型的一维数组(B[]),@后面是其内存地址,

62,615

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧