Android examples for Network:URL
url Validation
//package com.java2s; import java.net.HttpURLConnection; import java.net.URL; public class Main { public static boolean urlValidation(String url) { boolean success = false; URL sUrl = null;/*w w w . ja v a 2s. co m*/ HttpURLConnection conn = null; try { sUrl = new URL(url); conn = (HttpURLConnection) sUrl.openConnection(); conn.setConnectTimeout(5 * 1000); conn.setReadTimeout(10 * 1000); conn.connect(); if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { success = true; } } catch (Exception e) { } finally { if (null != conn) { conn.disconnect(); conn = null; } if (null != sUrl) { sUrl = null; } } return success; } }