Here you can find the source of addEscape(String a_unescaped)
Parameter | Description |
---|---|
a_unescaped | a parameter |
public static String addEscape(String a_unescaped)
//package com.java2s; /*// ww w. j a va2 s . c o m * @(#) StringUtils.java Jul 20, 2005 * Copyright 2005 Frequency Marketing, Inc. All rights reserved. * Frequency Marketing, Inc. PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ public class Main { /** * The string escape character */ public static final char ESCAPE_CHAR = '\\'; /** * Add escape characters (\) before each of the characters to escape and * each of the escape characters themselves. * @param a_unescaped * @return the escaped text string */ public static String addEscape(String a_unescaped) { String escaped = null; if (null != a_unescaped) { StringBuffer text = new StringBuffer(); char charToEscape = ','; char character; int length = a_unescaped.length(); for (int index = 0; index < length; index++) { character = a_unescaped.charAt(index); if (character == charToEscape || character == ESCAPE_CHAR) { text.append(ESCAPE_CHAR); } text.append(character); } escaped = text.toString(); } return escaped; } }