Does Java have any useful packages to get url directly? What are the following parameters?

for example, whether www.baidu.com?name=test&sex=1, can directly obtain the name or sex parameters in this url, or add parameters, for example, I now add a tool class like age=28, is there any recommendation, online, etc.

Jul.25,2021

String url = "http://www.baidu.com?a=1&b=2&c=3";
        int index = url.indexOf("?");
        String param = url.substring(index+1);

        String[] params = param.split("&");

        Map<String,String> map = new HashMap<>();

        for (String item:params) {
            String[] kv = item.split("=");
            map.put(kv[0],kv[1]);
        }

        System.out.println(map);
        
{aquired 1, baked 2, cased 3}


import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class UrlUtil {

    /**
     * urlget
     * 
     * @param url
     * @param name
     * @param value
     * @return url
     */
    public static String addOrReplaceParam(String url, String name, String value) {
        if(value==null ||"".equals(value))return url;
        
        try {
            value =URLEncoder.encode(value,"UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        
        if (url.indexOf("&" + name + "=") >= 0
                || url.indexOf("?" + name + "=") >= 0) {
            if (url.indexOf("&" + name + "=") >= 0) {
                url = url.replaceFirst("\\&" + name + "\\=\\w+\\&", "&" + name
                        + "=" + value + "&");
                url = url.replaceFirst("\\&" + name + "\\=\\w+", "&" + name
                        + "=" + value);
            } else {
                url = url.replaceFirst("\\?" + name + "\\=\\w+\\&", "?" + name
                        + "=" + value + "&");
                url = url.replaceFirst("\\?" + name + "\\=\\w+", "?" + name
                        + "=" + value);
            }
            return url;
        } else {
            if (url.indexOf("?") > 0)
                return url + "&" + name + "=" + value;
            else
                return url + "?" + name + "=" + value;
        }

    }
}

if spring-web is used, there is a UriComponentBuilder that can be used

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4487b-66461.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4487b-66461.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?