Here you can find the source of downloadFirstLineFromInternetQuietly(URL url)
public static String downloadFirstLineFromInternetQuietly(URL url)
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; import java.nio.charset.Charset; public class Main { public static String downloadFirstLineFromInternetQuietly(URL url) { BufferedReader reader = null; try {/* ww w.j av a2s . c o m*/ reader = new BufferedReader(new InputStreamReader(url.openStream(), Charset.forName("UTF-8"))); return reader.readLine(); } catch (IOException ioe) { return ""; } finally { closeQuietly(reader); } } /** * Close a stream quietly because we honestly don't care if a stream.close() * throws IOException */ public static void closeQuietly(Closeable cl) { if (cl == null) { return; } try { cl.close(); } catch (IOException ioe) { // do nothing } } }