Here you can find the source of getHost(String url)
Parameter | Description |
---|---|
url | The url to check. |
public static String getHost(String url)
//package com.java2s; //License from project: LGPL import java.net.MalformedURLException; import java.net.URL; public class Main { /**//from w w w . j a v a 2 s . c o m * Returns the lowercased hostname for the url or null if the url is not well * formed. * * @param url The url to check. * @return String The hostname for the url. */ public static String getHost(String url) { try { return new URL(url).getHost().toLowerCase(); } catch (MalformedURLException e) { return null; } } }