Java URL Connection getURL(String url)

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

Description

get URL

License

Open Source License

Declaration

public static String getURL(String url) throws IOException, MalformedURLException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010 Wolfgang Werner./*w  ww.  j a  v a2 s  . c o m*/
 * 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
 *
 * Contributors:
 *    Wolfgang Werner - initial API and implementation and/or initial documentation
 *******************************************************************************/

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

public class Main {
    public static String getURL(String url) throws IOException, MalformedURLException {
        URLConnection conn = new URL(url).openConnection();

        BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String result = in.readLine();
        return result;
    }
}

Related

  1. getStream(URL url)
  2. getStreamWithTimeOut(String stringUrl, Integer timeOutInMilli)
  3. getString(URL url)
  4. getType(URLConnection connection)
  5. getUrl(String serverName, String docid, String pageid)
  6. getUrlAsProperties(String urlString)
  7. getUrlContent(String urlAddress)
  8. getURLContents(URL u, Map data)
  9. getURLContentsAsString(URL url)