mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
refactor IPRange
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user