【发布时间】:2018-11-05 04:08:18
【问题描述】:
我正在通过蓝牙读取来自设备的恒定数据流。我想知道如何将这些数据转换为字符串并打印出来? 缓冲区将包含一个 ASCII 字符串,但是当我运行它时,它会打印出整数,我希望能够看到该字符串。
while (true) {
try {
//read the data from socket stream
if(mmInStream != null) {
int input = mmInStream.read(buffer);
System.out.println(input);
}
// Send the obtained bytes to the UI Activity
} catch (IOException e) {
//an exception here marks connection loss
//send message to UI Activity
break;
}
}
【问题讨论】:
-
您应该首先打印该缓冲区的内容。此外,您应该告诉我们阅读的内容。缓冲区将包含什么?
标签: java android bluetooth stream inputstream