How to read a zip file from a remote URL without extracting it
File
class is not designed to work with remote files. It only supports files that are available on a local file system. To open a stream on a remote file, you can use HttpURLConnection
.
Call getInputStream()
on an HttpURLConnection
instance to get an input stream that you can process further.
Example:
String url= "http://www.nseindia.com/content/historical/EQUITIES/2015/NOV/cm03NOV2015bhav.csv.zip";
InputStream is = new URL(url).openConnection().getInputStream();
None of the above has worked for me.
What did work like a charm, is this:
InputStream inputStream = new URL( urlString ).openStream();