java代码获取GPRS怎么获?
java代码获取GPRS怎么获取
// 初始化方法 public boolean init() { portList = CommPortIdentifier。getPortIdentifiers(); // 遍历端口 while (portList。hasMoreElements()) { portId = (CommPortIdentifier) portList。
nextElement(); // 串行端口 if (portId。getPortType() == CommPortIdentifier。PORT_SERIAL) { System。out。println(portId。getName()); // 端口号 if (portId。
getName()。equals("COM3")) { try { serialPort = (SerialPort) portId。open(this。getClass()。getName(), 5000);//这行报错 // 添加端口事件监听 serialPort。
addEventListener(this); serialPort。notifyOnDataAvailable(true); } catch (PortInUseException e) { e。printStackTrace(); return false; } catch (TooManyListenersException e) { return false; } try { is = serialPort。
getInputStream(); outputStream = serialPort。getOutputStream(); br = new BufferedReader(new InputStreamReader(is)); // 初始化串口 serialPort。
setSerialPortParams(9600,SerialPort。DATABITS_8, SerialPort。STOPBITS_1,SerialPort。PARITY_NONE); System。out。println("端口COM3初始化成功"); outputStream。
write("AT\r"。getBytes()); System。out。println(is。
read()); return true; } catch (IOException e) { return false; } catch (UnsupportedCommOperationException e) { return false; } } } } return false; }。
答:客户端发对了吗?协议不一致详情>>
答:google "java 缓冲池"详情>>
答:百度里搜张孝祥 非常好的视频教程详情>>