Java String Quote quote(String txt)

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

Description

quote

License

Open Source License

Declaration

public static String quote(String txt) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String quote(String txt) {
        StringBuffer sb = new StringBuffer("");
        sb.append(replace(replace(txt, "'", "'"), "", "'"));
        return sb.toString();
    }//www.j  a  v a2 s . co  m

    public static String replace(String str, String pattern, String replace) {
        int s = 0;
        int e = 0;
        StringBuffer result = new StringBuffer();

        if (str != null) {
            while ((e = str.indexOf(pattern, s)) >= 0) {
                result.append(str.substring(s, e));
                if (replace != null)
                    result.append(replace);
                s = e + pattern.length();
            }
            result.append(str.substring(s));
        }
        return result.toString();
    }
}

Related

  1. quote(String text)
  2. quote(String text)
  3. quote(String text)
  4. quote(String text, String quote)
  5. quote(String toQuote, String specials, char quoteChar)
  6. quote(String val)
  7. quote(String val)
  8. quote(String val, char quote)
  9. quote(String value)