谢谢

解决方案 »

  1.   

    try {
                Socket socket = new Socket(ip, port);
                if(socket.isConnected()){
                      System.out.println("端口被占用,连接打开!"); 
                      bl = true;
                }else{
                   System.out.println("端口被占用,连接没打开!"); 
                }
                bl = true;            
                socket.close();
                socket = null;
            } catch (IOException ex) {
                ex.printStackTrace();
                 System.out.println("端口没有使用!"); 
                bl = false;
            }
      

  2.   

    import java.io.ByteArrayOutputStream;
    import java.io.InputStream;/**
     * 
     * @author ronny_zeng
     * 
     */
    public class Exec {
    public static void main(String[] args) throws Exception { Process pro = Runtime.getRuntime().exec("cmd /c netstat -a "); InputStream is = pro.getInputStream();
    byte b;
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    while ((b = (byte) is.read()) != -1) {
    baos.write(b);
    } System.out.println(baos.toString()); }
    }
      

  3.   

    interpb(曾曾胡,深怕情多累美人!!!) 
    再写一个不调用系统命令的?