devxlogo

Encode and Decode URLs Using UTF-8

This tip shows you how to encode and decode your URLs using the UTF-8 character encoding:

import java.net.*;public class URL_Encoder_Decoder{	public static void main(String[] args){      String url = "@sir de caractere@,nr. 1290 'paragraf 3'";      try{         String encode_url=URLEncoder.encode(url,"UTF-8");         String decode_url=URLDecoder.decode(encode_url,"UTF-8");         System.out.println(url);         System.out.println(encode_url);           System.out.println(decode_url);               }catch(java.io.UnsupportedEncodingException e)              {System.out.println("Error:"+e.getMessage());}            	}}Output:@sir de caractere@,nr. 1290 'paragraf 3'%40sir+de+caractere%40%2Cnr.+1290+%27paragraf+3%27@sir de caractere@,nr. 1290 'paragraf 3'

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  How Engineering Leaders Spot Weak Proposals

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.