Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.net.URI;
import java.net.URISyntaxException;

public class Main {
    public static String getDomainName(String url) {

        String domain = "";

        URI uri;

        try {
            uri = new URI(url);
            domain = uri.getHost();
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }

        return domain.startsWith("www.") ? domain.substring(4) : domain;
    }
}