Get root domain from request

前端 未结 4 1671
青春惊慌失措
青春惊慌失措 2021-01-31 03:07

Consider the below URL as an example. http://www.test1.example.com

Is there any method by which I can get \"example.com\" as an output. I know there is

4条回答
  •  北海茫月
    2021-01-31 03:26

    import java.net.InetAddress;
    
    void Func() {
        InetAddress ia = InetAddress.getLocalHost();
        System.out.println (ia.getHostName());
    }
    

    Hope this helps.

提交回复
热议问题