Here you can find the source of getText(HttpURLConnection conn)
public static StringBuffer getText(HttpURLConnection conn)
//package com.java2s; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; public class Main { public static StringBuffer getText(HttpURLConnection conn) { try {//from ww w .j a v a 2s . c o m int rc = conn.getResponseCode(); String s = ""; StringBuffer html = new StringBuffer(); try { BufferedReader inp = new BufferedReader(new InputStreamReader(conn.getInputStream())); while ((s = inp.readLine()) != null) { s = s.replaceAll("http://istgeo.ist.supsi.ch:80/basemaps/wms/", "ciao"); System.out.println(s); html.append(s); } inp.close(); return html; } catch (Exception e) { System.out.println(e.getLocalizedMessage()); } } catch (IOException e) { System.out.println(e.getLocalizedMessage()); } return new StringBuffer(); } }