JAVA 串口读取16进制数问题
使用的是RXTXCOMM.JAR关键代码如下SerialPortserialPort;InputStreaminputStream;byte[]readBuffer=ne...
使用的是RXTXCOMM.JAR
关键代码如下
SerialPort serialPort;
InputStream inputStream;
byte[] readBuffer = new byte[1024];
int numBytes = 0;
inputStream = serialPort.getInputStream();
try {
while (inputStream.available() > 0) {
numBytes = inputStream.read(readBuffer);
System.out.print(new String(readBuffer));
}
} catch (IOException e) {
}
字符串可正常读取,但是16进制数读出的就是乱码 展开
关键代码如下
SerialPort serialPort;
InputStream inputStream;
byte[] readBuffer = new byte[1024];
int numBytes = 0;
inputStream = serialPort.getInputStream();
try {
while (inputStream.available() > 0) {
numBytes = inputStream.read(readBuffer);
System.out.print(new String(readBuffer));
}
} catch (IOException e) {
}
字符串可正常读取,但是16进制数读出的就是乱码 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询