Here you can find the source of generateMacOnIncrease(final String baseMac, final long l)
public static String generateMacOnIncrease(final String baseMac, final long l)
//package com.java2s; // Licensed to the Apache Software Foundation (ASF) under one import java.util.Formatter; public class Main { public static String generateMacOnIncrease(final String baseMac, final long l) { long mac = mac2Long(baseMac); if (l > 0xFFFFl) { return null; }/*from w w w. j a va2 s. c o m*/ mac = mac + (l << 24); mac = mac & 0x06FFFFFFFFFFl; return long2Mac(mac); } public static long mac2Long(final String macAddress) { final String[] tokens = macAddress.split(":"); assert tokens.length == 6; long result = 0; for (int i = 0; i < tokens.length; i++) { result = result << 8; result |= Integer.parseInt(tokens[i], 16); } return result; } public static String long2Mac(final long macAddress) { final StringBuilder result = new StringBuilder(17); try (Formatter formatter = new Formatter(result)) { formatter.format("%02x:%02x:%02x:%02x:%02x:%02x", macAddress >> 40 & 0xff, macAddress >> 32 & 0xff, macAddress >> 24 & 0xff, macAddress >> 16 & 0xff, macAddress >> 8 & 0xff, macAddress & 0xff); } return result.toString(); } }