Easy way to create a String using a StringPrinter.
960593
public static String buildString(Consumer<StringPrinter> printer) {
		StringBuilder builder = new StringBuilder();
		printer.accept(new StringPrinter(builder::append));
		return builder.toString();
	}
170347
def indent_string(string, *args)
      string = string.dup
      indent_string!(string, *args)
      string
    end
883317
def htmlprint(*values, plain=None, **options):
    
    print(*[htmlrender(x, plain=plain) for x in values], **options)
95582
public static String prettyPrint(String jsonPayload) {
        int indentSize = 0;
        // Just a guess that the pretty view will take 20 percent more than original.
        final CharBuf output = CharBuf.create((int) (jsonPayload.length() * 1.2));

        JsonLexer lexer = new JsonLexer(new StringReader(jsonPayload));
        // Will store already created indents.
        Map<Integer, char[]> indentCache = new HashMap<Integer, char[]>();
        while (lexer.hasNext()) {
            JsonToken token = lexer.next();
            switch (token.getType()) {
                case OPEN_CURLY:
                    indentSize += 4;
                    output.addChars(Chr.array(OPEN_BRACE, NEW_LINE)).addChars(getIndent(indentSize, indentCache));

                    break;
                case CLOSE_CURLY:
                    indentSize -= 4;
                    output.addChar(NEW_LINE);
                    if (indentSize > 0) {
                        output.addChars(getIndent(indentSize, indentCache));
                    }
                    output.addChar(CLOSE_BRACE);

                    break;
                case OPEN_BRACKET:
                    indentSize += 4;
                    output.addChars(Chr.array(OPEN_BRACKET, NEW_LINE)).addChars(getIndent(indentSize, indentCache));

                    break;
                case CLOSE_BRACKET:
                    indentSize -= 4;
                    output.addChar(NEW_LINE);
                    if (indentSize > 0) {
                        output.addChars(getIndent(indentSize, indentCache));
                    }
                    output.addChar(CLOSE_BRACKET);

                    break;
                case COMMA:
                    output.addChars(Chr.array(COMMA, NEW_LINE)).addChars(getIndent(indentSize, indentCache));

                    break;
                case COLON:
                    output.addChars(Chr.array(COLON, SPACE));

                    break;
                case STRING:
                    String textStr = token.getText();
                    String textWithoutQuotes = textStr.substring(1, textStr.length() - 1);
                    if (textWithoutQuotes.length() > 0) {
                        output.addJsonEscapedString(textWithoutQuotes);
                    } else {
                        output.addQuoted(Chr.array());
                    }

                    break;
                default:
                    output.addString(token.getText());
            }
        }

        return output.toString();
    }
1373291
public static String randomString(int length) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < length; i++) {
            int index = (int) random(0, ALL_CHAR.length() - 1);
            sb.append(ALL_CHAR.charAt(index));
        }
        return sb.toString();
    }
807389
public static String randomString(int length) {
        // CAUSE: If-Else Statements Should Use Braces
        if (length < 1) {
            throw new IllegalArgumentException(String.format("length < 1: %s", length));
        }

		char[] buf = new char[length];

		return nextString(buf);
	}
649957
def color_print(s, color=None, highlight=None, end='\n', file=sys.stdout,
                **kwargs):
    
    if color in palette and color != 'default':
        s = palette[color] + s
    # Highlight / Background color.
    if highlight and highlight in highlighter:
        s = highlighter[highlight] + s
    # Custom string format.
    for name, value in kwargs.items():
        if name in formatter and value == True:
            s = formatter[name] + s
    print(s + palette['default'], end=end, file=file)
173591
@Override
    public void prettyPrint(StringBuffer sb, int indent) {
        sb.append(Log.getSpaces(indent));
        sb.append(getClass().getSimpleName());
        sb.append(System.lineSeparator());

        sb.append(Log.getSpaces(indent + 2));
        sb.append("type: ");
        sb.append(getCameraRigType());
        sb.append(System.lineSeparator());

        sb.append(Log.getSpaces(indent + 2));
        sb.append("lookAt: ");
        float[] lookAt = getLookAt();
        for (float vecElem : lookAt) {
            sb.append(vecElem);
            sb.append(" ");
        }
        sb.append(System.lineSeparator());

        sb.append(Log.getSpaces(indent + 2));
        sb.append("leftCamera: ");
        if (leftCamera == null) {
            sb.append("null");
            sb.append(System.lineSeparator());
        } else {
            sb.append(System.lineSeparator());
            leftCamera.prettyPrint(sb, indent + 4);
        }

        sb.append(Log.getSpaces(indent + 2));
        sb.append("rightCamera: ");
        if (rightCamera == null) {
            sb.append("null");
            sb.append(System.lineSeparator());
        } else {
            sb.append(System.lineSeparator());
            rightCamera.prettyPrint(sb, indent + 4);
        }
    }
1323078
private Object prettyPrintValueString(final Object value) {
        if (value instanceof String) {
            return value.equals("") ? "\"\"" : value;
        } else {
            return value.toString();
        }
    }
309143
private static final String getString(CharacterIterator text, int start, int length) {
        StringBuilder result = new StringBuilder(length);
        int offset = text.getIndex();
        text.setIndex(start);
        for (int i = 0; i < length; i++) {
            result.append(text.current());
            text.next();
        }
        text.setIndex(offset);
        return result.toString();
    }
53873
def _print(self, *args):
        '''
        '''
        string = ' '.join([str(arg) for arg in args])
        print(string, end='', file=self._stream)
105485
void toStringRep(String indent, XAppender out) {
        out.append(indent).append("<");
        out.append(name);
        if (attributes.size() > 0) {
            for (String an : attributes.keySet()) {
                out.append(" ").append(an).append("='").append(sanitize(attributes.get(an))).append("'");
            }
        }

        if (children.size() == 0) {
            if (content == null) {
                out.append("/>");
            } else {
                out.append(">");
                out.append(sanitize(content));
                out.append("</");
                out.append(name);
                out.append(">");
            }
        } else {
            if (content == null) {
                out.append(String.format(">%n"));
            } else {
                out.append(">");
                out.append(sanitize(content));
                out.append(String.format("%n"));
            }
            for (XElement e : children) {
                e.toStringRep(indent + "  ", out);
            }
            out.append(indent).append("</");
            out.append(name);
            out.append(">");
        }
        out.append(String.format("%n"));
    }
1336401
private static <T extends GraphNode<T>> StringBuilder printTree(T node, Formatter<T> formatter,
                                                                    String indent, StringBuilder sb,
                                                                    Predicate<T> nodeFilter,
                                                                    Predicate<T> subTreeFilter) {
        if (nodeFilter.apply(node)) {
            String line = formatter.format(node);
            if (line != null) {
                sb.append(indent).append(line).append("\n");
                indent += "  ";
            }
        }
        if (subTreeFilter.apply(node)) {
            for (T sub : node.getChildren()) {
                printTree(sub, formatter, indent, sb, nodeFilter, subTreeFilter);
            }
        }
        return sb;
    }
25575
public String createString() {
        int i;
        int count;

        if (endPageIdx == 0) {
            // speedup the most frequent situation
            return new String(endPage, start, end - start);
        } else {
            char[] buffer;

            buffer = new char[endPageIdx * pageSize + end - start];
            count = pageSize - start;
            System.arraycopy(pages.get(0), start, buffer, 0, count);
            for (i = 1; i < endPageIdx; i++) {
                System.arraycopy(pages.get(i), 0, buffer, count, pageSize);
                count += pageSize;
            }
            System.arraycopy(pages.get(endPageIdx), 0, buffer, count, end);
            return new String(buffer);
        }
    }
616208
function stringify(str) {
            if (!str) {
                return str;
            }

            var newStr = '';
            for (var i = 0, l = str.length, ch; i < l; i++) {
                ch = str.charCodeAt(i);
                if (ch === 0) {
                    continue;
                }
                newStr += String.fromCharCode(ch);
            }
            return newStr;
        }
572940
def write(self, string):
        """"""
        string = string.rstrip()
        if string:  # Don't log empty lines
            self.logger.critical(string)
409416
def pretty_print_str(self):
        '''
        
        '''
        retval = ''
        # dfs
        todo = [self.root]
        while todo:
            current = todo.pop()
            for char in reversed(sorted(current.keys())):
                todo.append(current[char])
            indent = ' ' * (current.depth * 2)
            retval += indent + current.__unicode__() + '\n'
        return retval.rstrip('\n')