Code example for URLConnection

Methods: connect, getInputStream, setConnectTimeout, setReadTimeout

0
	 * @throws IOException 
	 */ 
	public boolean cacheURL(String url) throws IOException {
		URL ul = new URL(url);
		URLConnection conn = ul.openConnection();
		conn.setConnectTimeout(30 * 1000);
		conn.setReadTimeout(2 * 60 * 1000);
		conn.connect();
		return cache(conn.getInputStream(), url);
	} 
 
	/** 
	 * 将InputStream 进行缓存,并关闭相应的流。<br/> 缓存成功才会覆盖旧缓存 
	 *  
	 * @param input 
	 *            缓存的数据流 
	 * @param relativePathOrURL 
	 *            缓存的相对目录或资源的URL 
	 * @return true 缓存成功      false 缓存失败 
	 */ 
	public boolean cache(InputStream input, String relativePathOrURL) {