Here you can find the source of readText(final URL url)
public static String readText(final URL url) throws IOException
//package com.java2s; /*// w ww .java 2 s . c om * Copyright (C) 2011-2014 Brian Groenke * All rights reserved. * * This file is part of the 2DX Graphics Library. * * This Source Code Form is subject to the terms of the * Mozilla Public License, v. 2.0. If a copy of the MPL * was not distributed with this file, You can obtain one at * http://mozilla.org/MPL/2.0/. */ import java.io.*; import java.net.URL; public class Main { public static String readText(final URL url) throws IOException { String text = null; BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream())); StringBuilder sb = new StringBuilder(); String next; while ((next = br.readLine()) != null) { sb.append(next + System.getProperty("line.separator")); } br.close(); text = sb.toString(); return text; } }