When I am testing the list of url's to see if the connection is "alive" or "dead", I run into this site: (www.abbapregnancy.org) then site is blank with no information. How can I make an if statement to test for sites like this? Feel free to comment or suggest ideas. My code is currently like this:
try
{// Test URL Connection
URL url = new URL("http://www."+line);
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
wr = new OutputStreamWriter(conn.getOutputStream());
wr.flush();
rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
while( !rd.ready() ) {}
if( rd.ready())
{
//write to output file
System.out.println("Good URL: " + line);
urlAlive ++;
//increment alive line to Alive url file
aliveUrl += (line + System.getProperty("line.separator"));
}
else // increment dead url
urlDead++;
}
catch (Exception e)
// increment dead url
{
urlDead++;
}