I got the following code from the intenet
public boolean isConnectedToServer(String url, int timeout) {
try {
URL myUrl = new URL(url);
URLConnection connection = myUrl.openConnection();
connection.setConnectTimeout(timeout);
connection.connect();
return true;
} catch (Exception e) {
// Handle your exceptions
return false;
}
}
whenever i am calling this method :
System.out.println(isConnectedToServer("192.168.1.65",5));
the output is still false
and i can easily access my web service file so there is connectivity to this ip but i can't check if the ip is reachable, any thoughts ?
PS: using a local IP address just to connect to my XAMPP server
the Error:
java.net.MalformedURLException: Protocol not found: 192.168.1.65