I'm building a simple app that checks repeatedly changed made in certain file in a server.
I'm using HttpURLConnection
instance like so:
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL("https://www.aSite/alerts.json").openConnection();
try (InputStream inputStream = httpURLConnection.getInputStream())
{
...
}
I want to use this one connection to receive a response, but there is not a built in method for repeating the request. I fear that if I use the code block in a loop it will create new connection every time.
Is there a simple solution to this?