How to apply encoding to a string
3 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Filip_Filipov
Posted On:   Wednesday, January 9, 2002 08:30 AM

			

Hi,
How can one encode a string in the
standard URL encoding in order to use
that string in a url?
Thanks.
Filip

Re: How to apply encoding to a string

Posted By:   Martin_Jones  
Posted On:   Thursday, January 31, 2002 06:13 AM

Why not use BASE64 Encoding like a normalString could be encryted.




import java.security.MessageDigest;

import sun.misc.*;



public class Encoder

{


public static String encode(String input) throws Exception


{

return (new BASE64Encoder
().encode (MessageDigest.getInstance("SHA").digest(input.getBytes("UTF8"))));

}

}

Re: How to apply encoding to a string

Posted By:   Anonymous  
Posted On:   Wednesday, January 9, 2002 09:29 AM


String unencoded = "Hello World";
String encoded = java.net.URLEncoder.encode(unencoded);

Regards

Re: How to apply encoding to a string

Posted By:   Bozidar_Dangubic  
Posted On:   Wednesday, January 9, 2002 08:46 AM

java.net.URLEncoder has an encode() method you can use.
About | Sitemap | Contact