public static boolean getURL ( final String sUrl , final AtomicInteger gCount , long start ) { int count = gCount . incrementAndGet ( ) ; if ( count % 100 == 0 ) { long diff = ( System . currentTimeMillis ( ) - start ) / 1000 ; logger . info ( "Count: " + count + " IPS: " + count / diff ) ; } final URL url ; try { url = new URL ( sUrl ) ; } catch ( MalformedURLException e ) { logger . info ( "URL-Failed(" + count + "): " + e . toString ( ) ) ; return false ; } logger . log ( Level . FINE , "Testing(" + count + "): " + url ) ; final URLConnection con ; try { con = url . openConnection ( ) ; con . setConnectTimeout ( 10000 ) ; con . setReadTimeout ( 10000 ) ; if ( - 1 == con . getInputStream ( ) . read ( ) ) { return false ; } } catch ( IOException e ) { // don't print out time out as it is expected here if ( Utils . isIgnorableException ( e ) ) { return false ; } logger . log ( Level . WARNING , "Failed (" + url + ")(" + count + ")" , e ) ; return false ; } //logger.info(con); // logger.info("Date : " + new Date(con.getDate())); logger . info ( "Last Modified (" + url + ")(" + count + "): " + new Date ( con . getLastModified ( ) ) ) ; // logger.info( "Content encoding: " + con.getContentEncoding() // ); // logger.info( "Content type : " + con.getContentType() ); // logger.info( "Content length : " + con.getContentLength() ); return true ; }
Test URL and report if it can be read .