Here you can find the source of byteToMacString(byte[] data)
public static String byteToMacString(byte[] data)
//package com.java2s; /*/*from ww w.ja v a 2 s. co m*/ * Copyright (c) 2015 Yoyodyne, Inc. and others. 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 */ public class Main { public static String byteToMacString(byte[] data) { return hexStringToColonSeparatedString(bytesToHexString(data)); } public static String hexStringToColonSeparatedString(String input) { if (input == null) { return null; } StringBuffer buf = new StringBuffer(); for (int i = 0; i < input.length(); i += 2) { buf.append(input.charAt(i)); buf.append(input.charAt(i + 1)); if (i + 2 < input.length()) buf.append(":"); } return buf.toString(); } public static String bytesToHexString(byte[] bytes) { if (bytes == null) { return "null"; } String ret = ""; StringBuffer buf = new StringBuffer(); for (int i = 0; i < bytes.length; i++) { if (i > 0) { ret += ":"; } short u8byte = (short) (bytes[i] & 0xff); String tmp = Integer.toHexString(u8byte); if (tmp.length() == 1) { buf.append("0"); } buf.append(tmp); } ret = buf.toString(); return ret; } }