首页 新闻 会员 周边

JAVA写的串口通信程序--为什么在控制台了显示不了可用串口呢

0
悬赏园豆:5 [待解决问题]
 1 package test;
 2 import java.util.Enumeration;
 3 
 4 import javax.comm.*;
 5 
 6 class serialPort{
 7     
 8     public void ListPort(){
 9         Enumeration en = CommPortIdentifier.getPortIdentifiers();
10         CommPortIdentifier portID;
11         while(en.hasMoreElements()){
12             portID = (CommPortIdentifier)en.nextElement();
13             if(portID.getPortType() == CommPortIdentifier.PORT_SERIAL){
14                 System.out.println(portID.getName());
15                 
16             }
17         }
18         
19     }
20     
21 }
22 public class protect_one {
23 
24     public static void main(String[] args) {
25         serialPort serialport = new serialPort();
26         serialport.ListPort();
27         
28     }
29 }
jorks的主页 jorks | 初学一级 | 园豆:101
提问于:2015-06-22 23:52
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册