Here you can find the source of getInputStream(URL url)
static public InputStream getInputStream(URL url) throws IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2007, 2008 IBM Corporation and others. * 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.eclipse.org/legal/epl-v10.html * /*from w w w . j a v a2s .c o m*/ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ import java.io.*; import java.net.URL; public class Main { static public InputStream getInputStream(URL url) throws IOException { if (url == null) return null; try { return url.openStream(); } catch (FileNotFoundException e) { return null; // this is all right, means new file } } }