Here you can find the source of getIPV6AddrArray(String s)
private static int[] getIPV6AddrArray(String s)
//package com.java2s; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.StringTokenizer; public class Main { private static int[] getIPV6AddrArray(String s) { try {/*from w w w .java 2 s. co m*/ InetAddress inetaddress = InetAddress.getByName(s); s = inetaddress.getHostAddress(); } catch (UnknownHostException unknownhostexception) { System.err.println("unknown ipv6 exception"); } StringTokenizer stringtokenizer = new StringTokenizer(s, ":"); if (stringtokenizer.countTokens() != 8) return null; String[] as = new String[8]; for (int i = 0; i < 8; i++) { as[i] = stringtokenizer.nextToken(); } int[] ai = new int[16]; int j = 0; for (int k = 0; k < as.length; k++) { for (int l = as[k].length(); l < 4; l++) { as[k] = "0" + as[k]; } String s1 = as[k].substring(0, 2); String s2 = as[k].substring(2); try { ai[j++] = Integer.parseInt(s1, 16); ai[j++] = Integer.parseInt(s2, 16); } catch (NumberFormatException numberformatexception) { return null; } } for (int i1 = 0; i1 < 16; i1++) { if (ai[i1] < 0 || ai[i1] > 255) return null; } return ai; } }