private void setMacAddress(final String macAddress, final boolean setSourceMacAddress)
            throws IllegalArgumentException {
        if (macAddress == null || macAddress.isEmpty()) {
            throw new IllegalArgumentException("Null or empty string cannot be a valid MAC Address.");
        }
        // very naive implementation first.
        final String[] segments = macAddress.split(":");
        if (segments.length != 6) {
            throw new IllegalArgumentException("Invalid MAC Address. Not enough segments");
        }

        final int offset = setSourceMacAddress ? 6 : 0;
        for (int i = 0; i < 6; ++i) {
            final byte b = (byte) ((Character.digit(segments[i].charAt(0), 16) << 4) + Character.digit(segments[i]
                    .charAt(1), 16));
            this.headers.setByte(i + offset, b);
        }
    }
private void setMacAddress ( final String macAddress , final boolean setSourceMacAddress ) throws IllegalArgumentException { if ( macAddress == null || macAddress . isEmpty ( ) ) { throw new IllegalArgumentException ( "Null or empty string cannot be a valid MAC Address." ) ; } final String [ ] segments = macAddress . split ( ":" ) ; if ( segments . length != 6 ) { throw new IllegalArgumentException ( "Invalid MAC Address. Not enough segments" ) ; } final int offset = setSourceMacAddress ? 6 : 0 ; for ( int i = 0 ; i < 6 ; ++ i ) { final byte b = ( byte ) ( ( Character . digit ( segments [ i ] . charAt ( 0 ) , 16 ) << 4 ) + Character . digit ( segments [ i ] . charAt ( 1 ) , 16 ) ) ; this . headers . setByte ( i + offset , b ) ; } }
Helper method for setting the mac address in the header buffer.

@param macAddress
the mac address to parse
@param setSourceMacAddress
whether this is to bet set as the source mac address or not.
False implies destination mac address of course.
@throws IllegalArgumentException