您的位置:首页 > 其它

检测端口是否占用

2009-11-12 20:11 501 查看
import java.net.Socket;
import java.net.URISyntaxException;

public class Test {

/**
* @param args
* @throws URISyntaxException
*/
public static void main(String[] args) {
Socket s = null;
try {
s = new Socket("localhost", 61616);
System.out.println(s + "OK");
} catch (Exception exception) {
System.out.println(" ERROR");
} finally {
try {
if (s != null)
s.close();
} catch (Exception ee) {
}
}
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: