您可以使用Java Communications API进行此操作.我正在研究相同的java comm api和rxtx对此非常有效.我有一个为此编写的程序.干得好:
import java.io.*;
import java.util.*;
import javax.comm.*;
public class SimpleRead implements Runnable, SerialPortEventListener {
static CommPortIdentifier portId;
static Enumeration portList;
InputStream inputStream;
SerialPort serialPort;
Thread readThread;
public static void main(String[] args) {
portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
if (portId.getName().equals("COM13")) {
// if (portId.getName().equals("/dev/term/a")) {
SimpleRead reader = new SimpleRead();