@Test public void testBytes2IpString() throws IPStringConversionException { IPv6 ip = new IPv6(ipv4Mixed_bytes); assertTrue("Expected Bytes2IpString to work",ipv4Mixed_uncompressed.equals(ip.getString())); }
public static String bytes2IpString(byte[] in) throws IPStringConversionException { int i; int hi; int lo; StringBuilder sb; String hex; if (in.length != 16) { String msg = "Error IPv6 requires byte array of length 16"; throw new IPStringConversionException(msg); } sb = new StringBuilder(); for (i = 0; i < 14; i += 2) { hi = IPUtils.ubyte2int(in[i]) << 8; lo = IPUtils.ubyte2int(in[i + 1]); hex = String.format("%s:", IPUtils.int16bit2hex(hi | lo)); sb.append(hex); } hi = IPUtils.ubyte2int(in[14]) << 8; lo = IPUtils.ubyte2int(in[15]); sb.append(String.format("%s", IPUtils.int16bit2hex(hi | lo))); return sb.toString(); }
IPv6 { public static String bytes2IpString(byte[] in) throws IPStringConversionException { int i; int hi; int lo; StringBuilder sb; String hex; if (in.length != 16) { String msg = "Error IPv6 requires byte array of length 16"; throw new IPStringConversionException(msg); } sb = new StringBuilder(); for (i = 0; i < 14; i += 2) { hi = IPUtils.ubyte2int(in[i]) << 8; lo = IPUtils.ubyte2int(in[i + 1]); hex = String.format("%s:", IPUtils.int16bit2hex(hi | lo)); sb.append(hex); } hi = IPUtils.ubyte2int(in[14]) << 8; lo = IPUtils.ubyte2int(in[15]); sb.append(String.format("%s", IPUtils.int16bit2hex(hi | lo))); return sb.toString(); } }
IPv6 { public static String bytes2IpString(byte[] in) throws IPStringConversionException { int i; int hi; int lo; StringBuilder sb; String hex; if (in.length != 16) { String msg = "Error IPv6 requires byte array of length 16"; throw new IPStringConversionException(msg); } sb = new StringBuilder(); for (i = 0; i < 14; i += 2) { hi = IPUtils.ubyte2int(in[i]) << 8; lo = IPUtils.ubyte2int(in[i + 1]); hex = String.format("%s:", IPUtils.int16bit2hex(hi | lo)); sb.append(hex); } hi = IPUtils.ubyte2int(in[14]) << 8; lo = IPUtils.ubyte2int(in[15]); sb.append(String.format("%s", IPUtils.int16bit2hex(hi | lo))); return sb.toString(); } IPv6();  IPv6(String ip);  IPv6(byte[] in); }
IPv6 { public static String bytes2IpString(byte[] in) throws IPStringConversionException { int i; int hi; int lo; StringBuilder sb; String hex; if (in.length != 16) { String msg = "Error IPv6 requires byte array of length 16"; throw new IPStringConversionException(msg); } sb = new StringBuilder(); for (i = 0; i < 14; i += 2) { hi = IPUtils.ubyte2int(in[i]) << 8; lo = IPUtils.ubyte2int(in[i + 1]); hex = String.format("%s:", IPUtils.int16bit2hex(hi | lo)); sb.append(hex); } hi = IPUtils.ubyte2int(in[14]) << 8; lo = IPUtils.ubyte2int(in[15]); sb.append(String.format("%s", IPUtils.int16bit2hex(hi | lo))); return sb.toString(); } IPv6();  IPv6(String ip);  IPv6(byte[] in); static int[] splitvals(String ipStr); static int countnegatives(int[] in); static String expand(String ipStr, int nwords); String expand(); static int[] expand(int[] vals, int nwords); static byte[] IpString2bytes(String ipStr); static String bytes2IpString(byte[] in); void setIp(byte[] in); String getString(); byte[] getBytes(); void setIp(String ip); }
IPv6 { public static String bytes2IpString(byte[] in) throws IPStringConversionException { int i; int hi; int lo; StringBuilder sb; String hex; if (in.length != 16) { String msg = "Error IPv6 requires byte array of length 16"; throw new IPStringConversionException(msg); } sb = new StringBuilder(); for (i = 0; i < 14; i += 2) { hi = IPUtils.ubyte2int(in[i]) << 8; lo = IPUtils.ubyte2int(in[i + 1]); hex = String.format("%s:", IPUtils.int16bit2hex(hi | lo)); sb.append(hex); } hi = IPUtils.ubyte2int(in[14]) << 8; lo = IPUtils.ubyte2int(in[15]); sb.append(String.format("%s", IPUtils.int16bit2hex(hi | lo))); return sb.toString(); } IPv6();  IPv6(String ip);  IPv6(byte[] in); static int[] splitvals(String ipStr); static int countnegatives(int[] in); static String expand(String ipStr, int nwords); String expand(); static int[] expand(int[] vals, int nwords); static byte[] IpString2bytes(String ipStr); static String bytes2IpString(byte[] in); void setIp(byte[] in); String getString(); byte[] getBytes(); void setIp(String ip);  }