Java Mac Address to String macToString(long macAddress)

Here you can find the source of macToString(long macAddress)

Description

mac To String

License

Apache License

Declaration

public static String macToString(long macAddress) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String macToString(long macAddress) {
        String value = String.format("%012x", macAddress);
        char[] chars = value.toCharArray();

        final StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(chars[0]).append(chars[1]);
        for (int pos = 2; pos < value.length(); pos += 2) {
            stringBuilder.append(":").append(chars[pos]).append(chars[pos + 1]);
        }// www . ja va  2s  .c  o m

        return stringBuilder.toString();
    }
}

Related

  1. macToBinary(String mac)
  2. macToStr(byte[] mac)
  3. macToString(byte[] mac)
  4. macToString(byte[] mac)
  5. macToString(final byte[] address)
  6. macToString(String srcstr)