String[] ips = ipValue.split("//.");
String binaryVal = "";
for (int i = 0; i < ips.length; i++)
{
String binaryStr = Integer.toBinaryString(Integer.parseInt(ips[i]));
Integer times = 8 - binaryStr.length();
for(int j = 0; j < times; j++)
{
binaryStr = "0" + binaryStr;
}
binaryVal += binaryStr;
}
String regx = "^[1]*[0]*$";
if(isRegx(binaryVal, regx))
{
return true;
}
轉載請著名出處: 找網網-職業(程式員 UI設計 産品經理...)常用網站導航