Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

131
Views
decodeURI in java

I want to decode this uri in java:

URLDecoder.decode("/demo/%E4%B8%AD%E6%96%87/test%3Fa%3Da", UtilConst.UTF8);
// return "/demo/中文/test?a=a"

This is not my expected result, since it change the uri structure。I want to get the same result like JavaScript encodeURI method:

decodeURI('/demo/%E4%B8%AD%E6%96%87/test%3Fa%3Da');
// return "/demo/中文/test%3Fa%3Da"

How can I do this?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

String url = "/demo/%E4%B8%AD%E6%96%87/test%3Fa%3Da";
StringJoiner decoded = new StringJoiner("/");

String[] splittedUrl = url.split("/");
for (String item : splittedUrl) {
    if (!item.startsWith("%")) {
        decoded.add(item);
    } else {
        decoded.add(URLDecoder.decode(item, StandardCharsets.UTF_8));
    }
}
System.out.println(decoded); // /demo/中文/test%3Fa%3Da
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!