Get the second level domain of an URL (java)

前端 未结 10 920
长发绾君心
长发绾君心 2020-12-06 01:04

I am wondering if there is a parser or library in java for extracting the second level domain (SLD) in an URL - or failing that an algo or regex for doing the same. For exam

10条回答
  •  盖世英雄少女心
    2020-12-06 01:28

    If you want the second-level domain, you can split the string on "." and take the last two parts. Of course, this assumes you always have a second-level domain that is not specific to the site (since it sounds like that's what you want).

提交回复
热议问题