Verify the URL in Java

Who knows how to use regular expressions to verify the URL format in Java?

thank you

Solution

A very sneaky way is:

try {
    new java.net.URI(myUrl);
} catch(URISyntaxException e) {
    // url badly formed
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>