You can use this code to check if a host is reachable:
import java.net.InetAddress;
private boolean isHostReachable(String host)
{
    try
    {
        return InetAddress.getByName(host).isReachable(500);
    }
    catch (IOException e)
    {
        System.out.err("Error while checking if host is reachable: " + host + ", error is: " + e.getMessage());
        return false;
    }
}
If needed, you can check connection speed to that host. You'll need some HttpClient / Connection object for that. Idea is to send Http request, wait for response and measure elapsed time. Pseudocode to do it:
     long startTime = System.currentTimeMillis();
     //Write this above before your httprequest 
          HttpResponse httpResponse = httpClient.execute(httpGet);
          HttpEntity httpEntity = httpResponse.getEntity();
          is = httpEntity.getContent();    
    //After you get response  
    long elapsedTime = System.currentTimeMillis() - startTime;
    System.out.println("Total elapsed http request/response time in milliseconds: " + elapsedTime);
Basic tutorial for Http messaging: Using java.net.URLConnection to fire and handle HTTP requests