Here you can find the source of quote(String literal)
Parameter | Description |
---|---|
text | the content to quote. |
public static String quote(String literal)
//package com.java2s; /**/*from www. j a v a 2 s . com*/ * Converts a line of text into an array of lower case words using a * BreakIterator.wordInstance(). <p> * * This method is under the Jive Open Source Software License and was * written by Mark Imbriaco. * * @param text a String of text to convert into an array of words * @return text broken up into an array of words. */ public class Main { /** * Puts a quote before and after given string. * @param text the content to quote. * @return the quoted version of such content. */ public static String quote(String literal) { String result = ""; boolean t_bProcessed = true; if ((literal != null) && (literal.length() > 0)) { if (literal.charAt(0) != '\"') { if (literal.charAt(0) != '\'') { result = "\"" + literal + "\""; } else { if (literal.trim().length() > 0) { result = "\"" + literal.substring(1, literal.length() - 1) + "\""; } else { t_bProcessed = false; } } } else { result = literal; } } if (!t_bProcessed) { result = "\"\""; } return result; } }