Java String Escape addEscapeSequence(String inputStr)

Here you can find the source of addEscapeSequence(String inputStr)

Description

add Escape Sequence

License

Open Source License

Parameter

Parameter Description
inputStr a parameter

Return

String

Declaration

public static String addEscapeSequence(String inputStr) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*  w w w. ja v a2s  . c  om*/
     * @param inputStr
     * @return String
     */
    public static String addEscapeSequence(String inputStr) {
        if (inputStr.contains("\\")) {
            inputStr = inputStr.replace("\\", "\\\\");
        }
        if (inputStr.contains("\'")) {
            inputStr = inputStr.replace("\'", "\\\'");
        }
        if (inputStr.contains("\"")) {
            inputStr = inputStr.replace("\"", "\\\"");
        }
        return inputStr;
    }
}

Related

  1. addEscapeChar(String str)
  2. addEscapeCharactersForSpaces(String s)
  3. addEscapeCharsToBackSlash(String code)
  4. addEscapes(String s)
  5. addEscapes(String str)
  6. addEscapesToCode(String code)
  7. addEscChar(String str)
  8. escape(final @Nonnull String string)
  9. escape(final String s)