package jalview.util; import java.io.IOException; import java.io.InputStream; import java.net.URL; public class HttpUtils { /** * Returns true if it is possible to open an input stream at the given URL, * else false. The input stream is closed. * * @param url * @return */ public static boolean isValidUrl(String url) { InputStream is = null; try { is = new URL(url).openStream(); if (is != null) { return true; } } catch (IOException x) { // MalformedURLException, FileNotFoundException return false; } finally { if (is != null) { try { is.close(); } catch (IOException e) { // ignore } } } return false; } }