Java URL to InputStream getInputStream(URL url)

Here you can find the source of getInputStream(URL url)

Description

get Input Stream

License

Open Source License

Declaration

static public InputStream getInputStream(URL url) throws IOException 

Method Source Code

//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 
        }
    }
}

Related

  1. getInputStream(String url, int timeout)
  2. getInputStream(URL sourceURL)
  3. getInputStream(URL url)
  4. getInputStream(URL url)
  5. getInputStream(URL url)
  6. getInputStream(URL urlFile)
  7. getInputStream(URLConnection c)
  8. getInputStream(URLConnection connection)