Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.List; import java.util.Locale; public class Main { public static List<String> getRawBssidListByMacs(String macs, int macNum) { List<CharSequence> bssids = new ArrayList<CharSequence>(); for (int i = 0; i < macNum; i++) { StringBuilder sb = new StringBuilder(); bssids.add(sb); } int offset = macs.length() / macNum; for (int i = 0; i < macs.length(); i++) { char c = macs.charAt(i); StringBuilder sb = (StringBuilder) bssids.get(i / offset); sb.append(c); } List<String> result = new ArrayList<String>(); for (CharSequence cs : bssids) { result.add(getRawMacAddress(cs.toString())); } return result; } /** * Get the raw mac address from macAddress for Mesh. It is an inverse method for getMacAddressForMesh. * * @param macAddressForMesh the macAddress for Mesh * @return the raw mac address */ public static String getRawMacAddress(String macAddressForMesh) { StringBuilder sb = new StringBuilder(); char c; for (int i = 0; i < macAddressForMesh.length(); i++) { c = macAddressForMesh.charAt(i); sb.append(c); if (i % 2 != 0 && i != macAddressForMesh.length() - 1) { sb.append(':'); } } return sb.toString().toLowerCase(Locale.US); } }