Trying to understand java.net.InetAddress.isReachable() method
843790Feb 3 2007 — edited Mar 13 2007Hey guys,
I'm just testing some of the Java 6 API classes. So I'm playing with the isReachable() method.
I keep getting a syntax error when I try to use the method.
Let me show you what I'm trying to do:
------------------------------------------------------
import java.net.*;
import java.util.Scanner;
class NetTest {
public static void main(String[] args) {
Scanner netScan = new Scanner(System.in);
String myNet = netScan.next();
try {
InetAddress myAddr = InetAddress.getByName(myNet).isReachable(null, 0, 100);
}
catch (java.net.UnknownHostException exc) {
System.out.println("Can't find the host");
}
}
----------------------------------------------
I get the syntax error for the line with .isReachable saying:
"Type mismatch: cannot convert from boolean to InetAddress"
The rest works, just not the .isReachable. I've looked at the usage of the method in the API, and I guess I'm Just not getting it or something. Can somebody help? Much appreciated.