Java tutorial
//package com.java2s; public class Main { private static void test_getHostNameByMeshIp() { String meshIp = "C0A80102"; String result = getHostNameByMeshIp(meshIp); if (result.equals("192.168.1.2")) { System.out.println("test_getHostNameByMeshIp() pass"); } else { System.out.println("test_getHostNameByMeshIp() fail"); } } /** * Get the host name by mesh ip * * @param meshIp the mesh ip, e.g. C0A80102 * @return the ip address, e.g. 192.168.1.2 */ public static String getHostNameByMeshIp(String meshIp) { StringBuilder sb = new StringBuilder(); int value; for (int i = 0; i < meshIp.length(); i += 2) { value = Integer.parseInt(meshIp.substring(i, i + 2), 16); sb.append(value); sb.append("."); } return sb.substring(0, sb.length() - 1); } }