Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**
     * Check if the passed argument is a unicast MAC address.<br>
     * A unicast MAC address is the one with an even second hex.<br>
     * i.e. x[0,2,4,6,8,a,c,e]:xx:xx:xx:xx:xx
     * 
     * @return true if address is a unicast MAC address and false if not.
     */
    public static boolean isValidMACAddress(String address) {
        if (!address.matches("^[0-9a-fA-F][02468aceACE][:-]?([0-9a-fA-F]{2}[:-]?){4}[0-9a-fA-F]{2}$"))
            return false;
        return true;
    }
}