Gets the host from given url - Android Network

Android examples for Network:URL

Description

Gets the host from given url

Demo Code


//package com.java2s;
import android.net.Uri;

public class Main {
    /**/* w w  w .j a  v a2 s  .c  o  m*/
     * Gets the host from given url
     */
    public static String getHostFromUrl(String url) {
        Uri uri = Uri.parse(url);

        return uri.getHost();
    }
}

Related Tutorials