Java Mac Address to String macToBinary(String mac)

Here you can find the source of macToBinary(String mac)

Description

mac To Binary

License

Apache License

Declaration

public static byte[] macToBinary(String mac) 

Method Source Code

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

public class Main {
    public static byte[] macToBinary(String mac) {
        byte[] macBytes = new byte[6];
        try {/*from   ww w.ja v a2 s  .  c  o m*/
            String[] strArr = mac.split(":");
            for (int i = 0; i < strArr.length; i++) {
                int value = Integer.parseInt(strArr[i], 16);
                macBytes[i] = (byte) value;
            }
        } catch (Exception e) {
        }
        return macBytes;
    }
}

Related

  1. macToStr(byte[] mac)
  2. macToString(byte[] mac)
  3. macToString(byte[] mac)
  4. macToString(final byte[] address)