Here you can find the source of fetchURL(String url)
public static String fetchURL(String url)
//package com.java2s; /******************************************************************************* * Copyright (c) 2014 Gabriel Skantze./*w w w .j a va2 s . c o m*/ * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v3.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl.html * * Contributors: * Gabriel Skantze - initial API and implementation ******************************************************************************/ import java.net.URL; import java.net.URLConnection; import java.util.Scanner; public class Main { public static String fetchURL(String url) { String content = null; URLConnection connection = null; try { connection = new URL(url).openConnection(); Scanner scanner = new Scanner(connection.getInputStream()); scanner.useDelimiter("\\Z"); content = scanner.next(); return content; } catch (Exception ex) { ex.printStackTrace(); } return ""; } }