Code example for HttpURLConnection

Methods: getContentLengthgetInputStream

0
		private void createInputStream() { 
			// create InputStream with URL 
			InputStream is = null;
			try { 
				this.http = (HttpURLConnection) url.openConnection();
				this.fileSize = this.http.getContentLength();
				is = this.http.getInputStream();
			} catch (IOException e) {
				Log.e(DownloadMain.LOGTAG, e.toString());
			} 
 
			this.in = new BufferedInputStream(is);
		} 
 
		private void createOutputStream() { 
			// create a fileoutput to /sdcard/download 
			FileOutputStream fos = null;
			try { 
				fos = new FileOutputStream(DownloadMain.this.storageDir
						+ this.fileName);
Connect your IDE to all the code out there  Get Codota for Java