Here you can find the source of long2MacAddress(long l)
public static String long2MacAddress(long l)
//package com.java2s; //License from project: Open Source License public class Main { public static String long2MacAddress(long l) { StringBuilder sb = new StringBuilder(17); sb.append(toHex((byte) ((l >> 44) & 0xf))); sb.append(toHex((byte) ((l >> 40) & 0xf))); sb.append(":"); sb.append(toHex((byte) ((l >> 36) & 0xf))); sb.append(toHex((byte) ((l >> 32) & 0xf))); sb.append(":"); sb.append(toHex((byte) ((l >> 38) & 0xf))); sb.append(toHex((byte) ((l >> 24) & 0xf))); sb.append(":"); sb.append(toHex((byte) ((l >> 20) & 0xf))); sb.append(toHex((byte) ((l >> 16) & 0xf))); sb.append(":"); sb.append(toHex((byte) ((l >> 12) & 0xf))); sb.append(toHex((byte) ((l >> 8) & 0xf))); sb.append(":"); sb.append(toHex((byte) ((l >> 4) & 0xf))); sb.append(toHex((byte) (l & 0xf))); return sb.toString(); }//w w w. ja v a2s.co m public static char toHex(byte lowByte) { assert (lowByte < 16); if (lowByte < 10) { return (char) ('0' + lowByte); } else if (lowByte < 16) { return (char) ('A' + lowByte - 10); } else { return '?'; } } }