Java Utililty Methods String Java Encode

List of utility methods to do String Java Encode

Description

The list of methods to do String Java Encode are organized into topic(s).

Method

StringjavaEncode(String s)
Convert a string to a Java literal using the correct escape sequences.
int length = s.length();
StringBuilder buff = new StringBuilder(length);
for (int i = 0; i < length; i++) {
    char c = s.charAt(i);
    switch (c) {
    case '\t':
        buff.append("\\t");
        break;
...
StringjavaEncode(String s)
java Encode
StringBuffer result = new StringBuffer();
for (int i = 0; i < s.length(); i++)
    switch (s.charAt(i)) {
    case '\b':
        result.append("\\b");
        break;
    case '\t':
        result.append("\\t");
...
StringjavaEncode(String txt)
java Encode
if ((txt == null) || (txt.length() == 0)) {
    return txt;
txt = replaceEx(txt, "\\", "\\\\");
txt = replaceEx(txt, "\r\n", "\n");
txt = replaceEx(txt, "\n", "\\n");
txt = replaceEx(txt, "\"", "\\\"");
txt = replaceEx(txt, "'", "\\'");
...
StringjavaEncode(String txt)
java Encode
if ((txt == null) || (txt.length() == 0)) {
    return txt;
txt = replace(txt, "\\", "\\\\");
txt = replace(txt, "\r\n", "\n");
txt = replace(txt, "\r", "\\r");
txt = replace(txt, "\t", "\\t");
txt = replace(txt, "\n", "\\n");
...