Java String Quote quote(String input)

Here you can find the source of quote(String input)

Description

quote

License

LGPL

Declaration

private static CharSequence quote(String input) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    private static CharSequence quote(String input) {
        StringBuilder sb = new StringBuilder("");
        sb.append('"');
        for (char c : input.toCharArray()) {
            if (c == '\n') {
                sb.append("\\n");
                continue;
            }/*from   ww w  .j a va  2 s  . c  o  m*/
            if (c == '"' || c == '\'' || c == '\\') {
                sb.append('\\');
            }
            sb.append(c);
        }
        sb.append('"');
        return sb;
    }
}

Related

  1. quote(String content, String quoteMark)
  2. quote(String entityName)
  3. quote(String filepath)
  4. quote(String inp)
  5. quote(String input)
  6. quote(String literal)
  7. quote(String message, String quotationMark)
  8. quote(String name)
  9. quote(String name)