Here you can find the source of getAsStream(URL url)
protected static InputStream getAsStream(URL url) throws IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2006, 2007 Bug Labs, Inc.. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.buglabs.net/legal/epl_license.html *******************************************************************************/ import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.net.URLConnection; public class Main { protected static InputStream getAsStream(URL url) throws IOException { URLConnection conn = url.openConnection(); conn.setDoInput(true);/*from ww w .j av a2 s.co m*/ conn.setDoOutput(false); return conn.getInputStream(); } }