Code example for URLConnection

Methods: getContentLength, getInputStream

0
				throw ex;
			} 
		} else { 
			try { 
				URLConnection uc = url.openConnection();
				is = uc.getInputStream();
				capacityHint = uc.getContentLength();
				// Ignore insane values for Content-Length 
				if (capacityHint > (1 << 20)) {
					capacityHint = -1;
				} 
			} catch (IOException ex) {
				Context.reportError(getMessage("msg.couldnt.open.url", url.toString(), ex.toString()));
				throw ex;
			} 
		} 
		if (capacityHint <= 0) {
			capacityHint = 4096;
		} 
 
		byte[] data;