判断特定网址能不能正常浏览

String host = "192.168.10.91"; // 目标主机IP地址
int port = 2333; // 目标主机端口号

try {
    Socket socket = new Socket();
    socket.connect(new InetSocketAddress(host, port), timeout);
    System.out.println("可以正常浏览 " + host + ":" + port);
    socket.close();
} catch (IOException e) {
    System.out.println("无法正常浏览 " + host + ":" + port);
}

你可能感兴趣的:(java,服务器,tomcat)