I have the below code to read from a URL object:
URL url= new URL("http://datasource.com");
BufferedReader reader = new BufferedReader(
new InputStreamReader(url.openStream()));
After I am done getting the data, is this sufficient to close and release all the resrouces:
reader.close();
I did not see a method for URL to close it, like URL.close()...but wondering if I shouldn't do something more like this:
InputStreamReader inputStreamReader = new InputStreamReader(url.openStream());
BufferedReader reader = new BufferedReader(inputStreamReader);
// Do Stuff
inputStreamReader.close();
reader.close();