Java Byte Convert From bytesFromDpid(long dpid)

Here you can find the source of bytesFromDpid(long dpid)

Description

bytes From Dpid

License

Open Source License

Declaration

public static byte[] bytesFromDpid(long dpid) 

Method Source Code

//package com.java2s;
/*/*from   ww  w  .ja v  a 2  s  .c  om*/
 * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */

public class Main {
    public static byte[] bytesFromDpid(long dpid) {
        byte[] mac = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

        for (short i = 0; i < 6; i++) {
            mac[5 - i] = (byte) dpid;
            dpid >>= 8;
        }

        return mac;
    }
}

Related

  1. asByte(Byte number)
  2. asByte(final Object o)
  3. asByte(Object o)
  4. booleanAsByte(boolean val)
  5. bytesFrom(String hwAddress)
  6. bytesFromHex(String s)
  7. bytesFromHexString(String values)
  8. bytesFromLong(long l)
  9. bytesFromString(String bytes)