Get query string from a URL in Java
Description
The following code shows how to get query string from a URL.
Example
//from www . j a va 2s . co m
import java.net.URL;
public class Main {
public static void main(String[] args) throws Exception {
URL url = new URL("http://www.yahoo.com:80/en/index.html?name=joe#first");
System.out.println("query:" + url.getQuery());
}
}
The code above generates the following result.