Here you can find the source of encode(String str)
Parameter | Description |
---|---|
str | The string to encode. |
private static String encode(String str)
//package com.java2s; /**//w ww. ja v a 2 s. co m * The Heaton Research Spider Copyright 2007 by Heaton * Research, Inc. * * HTTP Programming Recipes for Java ISBN: 0-9773206-6-9 * http://www.heatonresearch.com/articles/series/16/ * * FormUtility: This class is used to construct responses to * HTML forms. The class supports both standard HTML forms, * as well as multipart forms. * * This class is released under the: * GNU Lesser General Public License (LGPL) * http://www.gnu.org/copyleft/lesser.html * * @author Jeff Heaton * @version 1.1 */ import java.io.*; import java.net.*; public class Main { private final static String encode = "UTF-8"; /** * Encode the specified string. This encodes all special * characters. * * @param str * The string to encode. * @return The encoded string. */ private static String encode(String str) { try { return URLEncoder.encode(str, encode); } catch (UnsupportedEncodingException e) { return str; } } }