refactor IPRange

This commit is contained in:
wenshao
2012-08-29 16:02:23 +08:00
parent 4f62fa4a4b
commit 2414acac32
@@ -257,18 +257,19 @@ public class IPRange {
}
public static String toDecimalString(String inBinaryIpAddress) {
String decimalip = new String();
StringBuilder decimalip = new StringBuilder();
String[] binary = new String[4];
for (int i = 0, c = 0; i < 32; i = i + 8, c++) {
binary[c] = inBinaryIpAddress.substring(i, i + 8);
int octet = Integer.parseInt(binary[c], 2);
decimalip = decimalip + Integer.toString(octet);
decimalip.append(octet);
if (c < 3) {
decimalip = decimalip + ".";
decimalip.append('.');
}
}
return decimalip;
return decimalip.toString();
}
// -------------------------------------------------------------------------