如何在Java中将URL分解为其组件部分? [英] How do I decompose a URL into its component parts in Java?
本文介绍了如何在Java中将URL分解为其组件部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的要求相当简单,但我需要做很多这样的事情,所以我正在寻找一个强大的解决方案。
My requirements are fairly simple, but I need to do a lot of this so I'm looking for a robust solution.
是否有一个很好的轻量级用于在Java中将URL分解为其组件部分的库?我指的是主机名,查询字符串等。
Is there a good light-weight library for decomposing URLs into their component parts in Java? I'm referring to hostname, query string, etc.
推荐答案
看看 java.net.URL 。它有完全符合您要求的方法。
Take a look at java.net.URL. It has methods for exactly what you're trying to do.
主机名: getHost()
查询字符串: getQuery()
Fragment / ref / anchor: getRef()
路径: getPath()
这篇关于如何在Java中将URL分解为其组件部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文