/** * Convert ip segment to hex. * * @param ipSegment * the ip segment * @return the string */ public static String convertIpSegmentToHex(String ipSegment) { return convertIpSegmentToHex(Integer.valueOf(ipSegment)); }
/** * Convert ipv4 ip to hex. * * @param ipAddress * the ip address * @return the string */ public static String convertIpv4IpToHex(String ipAddress) { StringBuffer hexIp = new StringBuffer(64); String[] ipSegments = ipAddress.split("\\."); for (String ipSegment : ipSegments) { hexIp.append(convertIpSegmentToHex(ipSegment)); } return hexIp.toString(); }