java实战 连接服务器

Last updated on November 20, 2024 am

🧙 Questions

☄️Ideas

/**
     * 测试服务器连接
     *
     * @param host www.baidu.com
     * @param port 22
     */
    public static boolean testServer(String host, int port) {

        Socket server = new Socket();
        InetSocketAddress address = new InetSocketAddress(host, port);

        // 测试连接
        try {
            server.connect(address, 3000);
        } catch (IOException e) {
            return false;
        }

        return true;
    }

String realFileName = fullFileName.substring(0, fullFileName.length() - fileSuffix.length() - 1);

java实战 连接服务器
https://ispong.isxcode.com/spring/java/java实战 连接服务器/
Author
ispong
Posted on
January 13, 2021
Licensed under