JBUILDER5 is down-regulated to get the whole process of host IP

zhaozj2021-02-17  54

1 New project, newly built a class

The program is very simple to analyze and use a function getAllByName ()

Enter the following code:

Import java.io. *; import java.net. *; ///// gethost.java///public class gethost {public static void main (string arg []) {if (arg.length> = 1 ) {Inetaddress [] inet; INT i = 1; try {for (i = 1; i <= arg.length; i ) {inet = inetaddress.getallbyName (arg [i-1]); for (int J = 1 J <= inet.length; j ) {system.out.print (inet [j-1] .tostring ()); system.out.print ("/ n");}}} catch (unknownhostexception e) { System.out.print ("Unknown Hostname!" Arg [i-1]);}}}} else {system.out.print ("USAGE JAVA / JVIEW Getip");}}}

2 At this point, select Project-> Project Propoties Enter the URL you want to query in the Application Parameters in the run in Tab, such as www.sohu.com, click Run, you can see the return IP address.

3 I am also debugging today, usually you only need to use the command line in JDK

Java gethost www.sohu.com is OK, but in JB

4 I will use JB's experience, one is to organize some information for beginners to learn, after all, this area is too small. I hope to have a master to make valuable advice to my experience, for my learning, thank you!

转载请注明原文地址:https://www.9cbs.com/read-30944.html

New Post(0)