List of utility methods to do IP Address to String
String | convertIpToString(byte[] ip) convert Ip To String sb.delete(0, sb.length()); for (int i = 0; i < ip.length; i++) { sb.append(ip[i] & 0xFF).append('.'); sb.deleteCharAt(sb.length() - 1); return sb.toString(); |
String | inputStreamContent(InputStream is) input Stream Content StringBuilder content = new StringBuilder(""); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is)); char[] buffer = new char[4096]; int charsRead; try { while ((charsRead = bufferedReader.read(buffer)) > 0) { content.append(buffer, 0, charsRead); } catch (IOException e) { e.printStackTrace(); throw e; } finally { bufferedReader.close(); return content.toString(); |
String | ip2string(byte[] ip) Converts the given bytes of an IP to a string representation. if (ip == null) { throw new NullPointerException("Ip is null!"); assert ip.length == 4; return (ip[0] & 0xff) + "." + (ip[1] & 0xff) + '.' + (ip[2] & 0xff) + '.' + (ip[3] & 0xff); |
String | ip2string(byte[] ips) ipstring int i = 0; String ipstr = ""; for (i = 0; i < ips.length - 1; i++) ipstr += (ips[i] & 0x00ff) + "."; ipstr += ips[i] & 0x00ff; return ipstr; |
String | ip2String(int ip) ip String return String.format("%d.%d.%d.%d", ip & 0xff, (ip >> 8) & 0xff, (ip >> 16) & 0xff, (ip >> 24) & 0xff); |
String | ipToIPv4Str(byte[] ip) ip To I Pv Str if (ip.length != 4) { return null; return new StringBuilder().append(ip[0] & 0xFF).append(".").append(ip[1] & 0xFF).append(".") .append(ip[2] & 0xFF).append(".").append(ip[3] & 0xFF).toString(); |
String | ipToString(final byte[] address) Convert specified array of bytes into an ip-string. final StringBuffer sb = new StringBuffer(address.length * 4); for (int i = 0; i < address.length; i++) { final int element = address[i] & 0xFF; if (0 != i) { sb.append('.'); sb.append(element); return sb.toString(); |
String | ipToString(final byte[] bytes) ip To String final StringBuffer addrStr = new StringBuffer(); for (int cnt = 0; cnt < bytes.length; cnt++) { final int uByte = bytes[cnt] < 0 ? bytes[cnt] + 256 : bytes[cnt]; addrStr.append(uByte); if (cnt < 3) addrStr.append('.'); return addrStr.toString(); ... |
String | IpToString(int address) Convert an IP address stored in an int to its string representation. StringBuffer sa = new StringBuffer(); for (int i = 0; i < 4; i++) { sa.append(0xff & address >> 24); address <<= 8; if (i != 4 - 1) sa.append('.'); return sa.toString(); ... |
String | IPToString(int intIP) IP To String StringBuilder sb = new StringBuilder(15); try { for (int i = 3; i >= 0; i--) { if (i != 3) sb.append('.'); sb.append((int) (intIP & 0xFF)); intIP = intIP >>> 8; } catch (Exception e) { e.printStackTrace(); return (sb.toString()); |