我有一个文本对象,包含如下信息。
Ethernet adapter 大网:
Connection-specific DNS Suffix . : xxxx.com
IP Address. . . . . . . . . . . . : 15.122.33.114
Subnet Mask . . . . . . . . . . . : 255.255.254.0
Default Gateway . . . . . . . . . : 10.121.32.11
Ethernet adapter 小网:
Connection-specific DNS Suffix . : xxxx.com
IP Address. . . . . . . . . . . . : 15.121.32.114
Subnet Mask . . . . . . . . . . . : 255.255.252.0
Default Gateway . . . . . . . . . : 15.121.32.13
我现在想把以上的信息包装成一个数组,数组中包的是单个网域对象。
如EthernetEntity对象有如下属性。String connDNS, String IPaddress,String SubMask,String DefaultGateway
帮忙解决哈。
先用回车符来split
得到的几行就是有内容得那几行
split的结果要trim一下 把首尾的空格去掉
再用:来判断
有:的 就是要分割的 然后可以用substring来取出key 和value以便构造lz需要的对象 了
是哦,对每一行用split(":")它返回的就是一个String[]数组