端口是否被占用
import cn.hutool.core.util.NetUtil;
int port = 8080;
if(!NetUtil.isUsableLocalPort(port)) {
System.err.printf("端口%d被占用了,无法启动%n", port );
System.exit(1);
}
端口是否被占用
import cn.hutool.core.util.NetUtil;
int port = 8080;
if(!NetUtil.isUsableLocalPort(port)) {
System.err.printf("端口%d被占用了,无法启动%n", port );
System.exit(1);
}