package allone.service.util; /** * * @author wangcheng * */ public class IPFormat { public static void main(String[] args) { IPFormat ipFormat=new IPFormat(); System.out.println("原始IP:192.168.000.001,转换结果:"+ipFormat.IPFormatTo0("192.168.000.001")); System.out.println("原始IP:192.168.0.1,转换结果:"+ipFormat.IPFormatTo000("192.168.0.1")); } public static String IPFormatTo0(String ipAddress){ String[] strs = ipAddress.split("\\."); int ip1 = Integer.valueOf(strs[0]).intValue(); int ip2 = Integer.valueOf(strs[1]).intValue(); int ip3 = Integer.valueOf(strs[2]).intValue(); int ip4= Integer.valueOf(strs[3]).intValue(); String ip=String.format("%1$01d.%2$01d.%3$01d.%4$01d", ip1,ip2,ip3,ip4); return ip; } public static String IPFormatTo000(String ipAddress){ String[] strs = ipAddress.split("\\."); int ip1 = Integer.valueOf(strs[0]).intValue(); int ip2 = Integer.valueOf(strs[1]).intValue(); int ip3 = Integer.valueOf(strs[2]).intValue(); int ip4= Integer.valueOf(strs[3]).intValue(); String ip=String.format("%1$03d.%2$03d.%3$03d.%4$03d", ip1,ip2,ip3,ip4); return ip; } }

谢LING LV1
2021年3月10日
低调人 LV38
2020年3月24日
luohaipeng LV23
2019年11月19日
dongzhan LV12
2019年5月6日
lxwlxwlxw LV8
2019年2月13日
十小时 LV12
2018年4月9日
wyx065747 LV67
2017年9月23日
yz520sisi LV1
2015年12月25日
zhang31123 LV23
2015年6月26日
king110108 LV7
2015年1月14日