Here you can find the source of convertIP6Address(byte[] bytes)
public static String convertIP6Address(byte[] bytes)
//package com.java2s; /**/*from ww w . j ava2s . co m*/ * Copyright (c) 2011, 2014 Eurotech and/or its affiliates * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Eurotech */ public class Main { public static byte[] convertIP6Address(String fullFormIP6Address) { byte[] retVal = new byte[16]; String[] ip6Split = fullFormIP6Address.split(":"); for (int i = 0; i < 8; i++) { ; String octet = ip6Split[i]; StringBuffer sb = new StringBuffer(); while ((sb.length() + octet.length()) < 4) { sb.append("0"); } sb.append(octet); retVal[i * 2] = (byte) Short.parseShort(sb.toString().substring(0, 2), 16); retVal[i * 2 + 1] = (byte) Short.parseShort(sb.toString().substring(2, 4), 16); } return retVal; } public static String convertIP6Address(byte[] bytes) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < 16; i = i + 2) { sb.append(Integer.toHexString(0xFF & bytes[i])); sb.append(Integer.toHexString(0xFF & bytes[i + 1])); if (i != 14) { sb.append(":"); } } return sb.toString(); } }