Here you can find the source of readURL(URLConnection connection, String charset)
public static String readURL(URLConnection connection, String charset) throws IOException
//package com.java2s; /**// ww w .j a v a2s. c o m * aTunes 1.6.0 * Copyright (C) 2006-2007 Alex Aranda (fleax) alex.aranda@gmail.com * * http://www.atunes.org * http://sourceforge.net/projects/atunes * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ import java.io.IOException; import java.io.InputStream; import java.net.URLConnection; public class Main { public static String readURL(URLConnection connection) throws IOException { StringBuilder builder = new StringBuilder(); InputStream input = connection.getInputStream(); byte[] array = new byte[1024]; int read; while ((read = input.read(array)) > 0) { builder.append(new String(array, 0, read, "UTF-8")); } return builder.toString(); } public static String readURL(URLConnection connection, String charset) throws IOException { StringBuilder builder = new StringBuilder(); InputStream input = connection.getInputStream(); byte[] array = new byte[1024]; int read; while ((read = input.read(array)) > 0) { builder.append(new String(array, 0, read, charset)); } return builder.toString(); } }