public String readURL(URL url) throws IOException {
  try {
    StringBuilder builder;
    try (InputStreamReader in=new InputStreamReader(url.openStream(),StandardCharsets.UTF_8);BufferedReader reader=new BufferedReader(in)){
      builder=new StringBuilder();
      String aux;
      while ((aux=reader.readLine()) != null) {
        builder.append(aux);
      }
    }
     return builder.toString();
  }
 catch (  NullPointerException ex) {
    return null;
  }
}

public String readURL ( URL url ) throws IOException { try { StringBuilder builder ; try ( InputStreamReader in = new InputStreamReader ( url . openStream ( ) , StandardCharsets . UTF_8 ) ; BufferedReader reader = new BufferedReader ( in ) ) { builder = new StringBuilder ( ) ; String aux ; while ( ( aux = reader . readLine ( ) ) != null ) { builder . append ( aux ) ; } } return builder . toString ( ) ; } catch ( NullPointerException ex ) { return null ; } }
read a text url into a string . would be significantly simpler with java 7 . file is assumed to be encoded using utf - 8
