import java.net.*;
public class TestInet1 {
public static void main(String argv[])
{
try {
InetAddress myip = InetAddress.getLocalHost();
System.out.println(myip.getHostName());
System.out.println(myip.getHostAddress());
} catch (UnknownHostException e) {
System.out.println("Error: unable to resolve localhost");
}
}
}
來源:http://xml-nchu.blogspot.tw/2012/12/java.html
步驟依舊
輸入javac 貼上檔案名+副檔名輸入java 貼上檔案名
沒有留言:
張貼留言