I have around 5000 URL links. I want to check the HTTP status of each link.
Also, if all you care about is the response code, try setting the request method to "HEAD" using connection.setRequestMethod("HEAD"). This will cause the server to return only the headers, and not the full body of the HTML document, which you're ignoring anyways. This will save you bandwidth, and your URL checker will run a lot faster.