How do I replace special characters with URL encoders.?

This example shows you how to replace special characters with URL encoders.
package net.javaiq.examples.http;

/**
 * This class demonstrates on how to replace special characters with URL encoders. 
 * @author JavaIQ.net
 * Creation Date Dec 10, 2010
 */
public class UrlEncoder {

    /**
     *  method to give URL encoded characters for the given special characters
     */
    public static String replaceSpecialCharactersWithUrlEncoders(String urlToEncode) {
        if (urlToEncode != null) {
            if ((urlToEncode).contains("\'")) {
                urlToEncode = urlToEncode.replace("\'", " ");
            }
            if ((urlToEncode).contains("\"")) {
                urlToEncode = urlToEncode.replace("\"", "%22");
            }

            if ((urlToEncode).contains("#")) {
                urlToEncode = urlToEncode.replace("#", "%23");
            }
            if ((urlToEncode).contains("$")) {
                urlToEncode = urlToEncode.replace("$", "%24");
            }
            if ((urlToEncode).contains("%")) {
                urlToEncode = urlToEncode.replace("%", "%25");
            }
            if ((urlToEncode).contains("&")) {
                urlToEncode = urlToEncode.replace("&", "%26");
            }
            if ((urlToEncode).contains("@")) {
                urlToEncode = urlToEncode.replace("@", "%40");
            }
        }
        return urlToEncode;
    }

    /**
     * Method to test other methods in the class with sample inputs
     * @param args
     */
    public static void main(String[] args) {

    }

}