Java HTTP Read getInputStream(String url)

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

Description

get Input Stream

License

Open Source License

Parameter

Parameter Description
string a parameter

Exception

Parameter Description
IOException an exception

Declaration

private static InputStream getInputStream(String url) throws IOException 

Method Source Code

//package com.java2s;
/*//  www .  j ava  2s .c o  m
 * #%L
 * Intuit Tank Api
 * %%
 * Copyright (C) 2011 - 2015 Intuit 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.eclipse.org/legal/epl-v10.html
 * #L%
 */

import java.io.IOException;
import java.io.InputStream;

import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
    /**
     * @param string
     * @return
     * @throws IOException
     */
    private static InputStream getInputStream(String url) throws IOException {
        HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection();
        con.setRequestMethod("GET");
        con.setConnectTimeout(3000);
        return con.getInputStream();
    }
}

Related

  1. getHtmlByteArray(final String url)
  2. getHtmlContent(String url)
  3. getInputStream(HttpURLConnection conn)
  4. getInputStream(HttpURLConnection connection)
  5. getInputStream(String myUrl)
  6. getInputStreamFromURL(String urlname)
  7. getInputStreamFromUrl(String urlString)
  8. getInputStreamReader(String httpUrl, int timeout)
  9. getJsonFromUrlWithJsonParameter(String url, String jsonRequest)