public class Ports extends Object
| Modifier and Type | Method and Description |
|---|---|
static List<Integer> |
getClosePorts(String host,
int[] ports)
获取未开启的端口
|
static List<Integer> |
getClosePorts(String host,
int[] ports,
int timeout)
获取未开启的端口
|
static List<Integer> |
getClosePorts(String host,
int start,
int end)
获取未开启的端口
|
static List<Integer> |
getClosePorts(String host,
int start,
int end,
int timeout)
获取未开启的端口
|
static int |
getFreePort()
获取一个空闲的本地端口
|
static int |
getFreePort(int[] ports)
获取一个空闲的本地端口
|
static int |
getFreePort(int start,
int end)
获取一个空闲的本地端口
|
static List<Integer> |
getFreePorts(int[] ports)
获取空闲的本地端口
|
static List<Integer> |
getFreePorts(int start,
int end)
获取空闲的本地端口
|
static List<Integer> |
getOpenPorts(String host,
int[] ports)
获取已开启的端口
|
static List<Integer> |
getOpenPorts(String host,
int[] ports,
int timeout)
获取已开启的端口
|
static List<Integer> |
getOpenPorts(String host,
int start,
int end)
获取已开启的端口
|
static List<Integer> |
getOpenPorts(String host,
int start,
int end,
int timeout)
获取已开启的端口
|
static List<Integer> |
getUsedPorts(int[] ports)
获取占用的本地端口
|
static List<Integer> |
getUsedPorts(int start,
int end)
获取占用的本地端口
|
static boolean |
isClose(String host,
int port)
判断端口是否关闭
|
static boolean |
isClose(String host,
int port,
int timeout)
判断端口是否关闭
|
static boolean |
isFree(int port)
判断端口是否空闲
|
static boolean |
isOpen(String host,
int port)
判断端口是否开启
|
static boolean |
isOpen(String host,
int port,
int timeout)
判断端口是否开启
|
static boolean |
isUsed(int port)
判断端口是否占用
|
public static int getFreePort()
public static int getFreePort(int[] ports)
ports - portspublic static int getFreePort(int start,
int end)
start - 端口开始end - 端口结束public static List<Integer> getFreePorts(int[] ports)
ports - portspublic static List<Integer> getFreePorts(int start, int end)
start - 端口开始end - 端口结束public static List<Integer> getUsedPorts(int[] ports)
ports - portspublic static List<Integer> getUsedPorts(int start, int end)
start - 端口开始end - 端口结束public static boolean isFree(int port)
port - 端口public static boolean isUsed(int port)
port - 端口public static boolean isOpen(String host, int port)
host - hostport - portpublic static boolean isOpen(String host, int port, int timeout)
host - hostport - porttimeout - timeoutpublic static boolean isClose(String host, int port)
host - 主机port - 端口public static boolean isClose(String host, int port, int timeout)
host - hostport - porttimeout - timeoutpublic static List<Integer> getOpenPorts(String host, int[] ports)
host - hostports - portspublic static List<Integer> getOpenPorts(String host, int[] ports, int timeout)
host - hostports - portstimeout - timeoutpublic static List<Integer> getOpenPorts(String host, int start, int end)
host - hoststart - startend - endpublic static List<Integer> getOpenPorts(String host, int start, int end, int timeout)
host - hoststart - startend - endtimeout - timeoutpublic static List<Integer> getClosePorts(String host, int[] ports)
host - hostports - portspublic static List<Integer> getClosePorts(String host, int[] ports, int timeout)
host - hostports - portstimeout - timeoutpublic static List<Integer> getClosePorts(String host, int start, int end)
host - hoststart - startend - endCopyright © 2025. All rights reserved.