Java String Quote quoteEach(String string)

Here you can find the source of quoteEach(String string)

Description

quote Each

License

Open Source License

Declaration

public static String quoteEach(String string) 

Method Source Code

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

public class Main {
    public static String quoteEach(String string) {
        String[] pieces = string.split("(\\s)+");
        StringBuffer result = new StringBuffer();
        for (String piece : pieces) {
            if (piece.indexOf("\"") >= 0) {
                // already quoted
                return string;
            }/*w w  w  .j a  v a2 s. c o m*/
            if (!piece.isEmpty()) {
                result.append(" \"");
                result.append(piece);
                result.append("\"\n");
            }
        }
        return result.toString();
    }
}

Related

  1. quotedString(String in, boolean backslashIsEscape)
  2. quotedString(String str)
  3. quotedString(String string)
  4. quotedString(String text)
  5. quotedStringOrNull(String string)
  6. quoteEscape(final String original)
  7. quoteEscaped(String input)
  8. quoteExecutable(String executable)
  9. quoteFileName(String filename)