论坛首页 Java企业应用论坛

简单的几句代码,输入就是乱码,对字符串编码有研究的请进

浏览 1087 次
该帖已经被评为隐藏帖
作者 正文
   发表时间:2009-09-07   最后修改:2009-09-07
OO
列出我的笔记本上可用的网络接口,但是,无论如何就是乱码,代码非常简单,如下:
package examples.a06;

import java.net.NetworkInterface;
import java.util.Enumeration;

public class InterfaceLister {
	public static void main(String[] args) throws Exception {
		Enumeration interfaces = NetworkInterface.getNetworkInterfaces();
		while (interfaces.hasMoreElements()) {
			NetworkInterface ni = (NetworkInterface) interfaces.nextElement();
			System.out.println(ni);
		}
	}
}

输出是:
name:lo (MS TCP Loopback interface) index: 1 addresses:
/127.0.0.1;

name:eth0 (W-ibeda virtual adapter - ????ü??????ò?????) index: 2 addresses:

name:eth1 (Broadcom NetLink (TM) Fast Ethernet - ????ü??????ò?????) index: 65540 addresses:
/192.168.0.100;

name:eth2 (Intel(R) Wireless WiFi Link 5100 - ????ü??????ò?????) index: 458757 addresses:

name:ppp0 (WAN (PPP/SLIP) Interface) index: 786438 addresses:
/117.88.171.252;

那位高手可以将乱码正确显示出来?
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics