Here you can find the source of encodeString(String s)
Parameter | Description |
---|---|
s | string to be encoded |
public static String encodeString(String s)
//package com.java2s; /*/*from w ww . j a v a2 s.c o m*/ * Copyright (C) 2002-2014 FlyMine * * This code may be freely distributed and modified under the * terms of the GNU Lesser General Public Licence. This should * be distributed with the code. See the LICENSE file for more * information or http://www.gnu.org/copyleft/lesser.html. * */ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; public class Main { /** * Encodes string to be URL safe. For encoding URL use encodeURL * method. * * @param s string to be encoded * @return encoded string */ public static String encodeString(String s) { try { return URLEncoder.encode(s, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new RuntimeException("string encoding failed", e); } } }