Example usage for edu.stanford.nlp.util StringUtils repeat

List of usage examples for edu.stanford.nlp.util StringUtils repeat

Introduction

In this page you can find the example usage for edu.stanford.nlp.util StringUtils repeat.

Prototype

public static String repeat(char ch, int times) 

Source Link

Usage

From source file:LVCoref.Utils.java

License:Open Source License

public static String prettyJSON(String s) {
    int indent = 0;
    String tab = "  ";
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < s.length(); i++) {
        Character c = s.charAt(i);
        if (c == '[' || c == '{') {
            sb.append(c);//w  ww  . j a  va  2 s  . c  o m
            sb.append('\n');
            indent++;
            sb.append(StringUtils.repeat(tab, indent));
        } else if (c == ',') {
            sb.append(c);
            sb.append('\n');
            sb.append(StringUtils.repeat(tab, indent));
        } else if (c == ']' || c == '}') {
            sb.append('\n');
            indent--;
            sb.append(StringUtils.repeat(tab, indent));
            sb.append(c);
        } else {
            sb.append(c);
        }
    }
    return sb.toString();
}