我有以下简单的代码,旨在检测给定的 IPv4 地址确实只有数值(即在去除点之后):
import edu.gcc.processing.exceptions.net.IPAddressNumericException;
//Get the IP address
String address = "239.255.255.255";
//Check to see if this is a number
try {
String IPNumbers = address.replace(".", "");
Integer.parseInt(IPNumbers);
} catch (NumberFormatException e) {
System.out.print(e.getMessage());
}
出于某种原因,NumberFormatException
被解雇了,我收到了这个错误:
For input string: "239255255255"
有人可以帮我理解这一点吗?该parseInt()
方法适用于较小的数字,例如127001
.
感谢您的时间。