List of usage examples for org.apache.commons.lang3 StringUtils rightPad
public static String rightPad(final String str, final int size)
Right pad a String with spaces (' ').
The String is padded to the size of size .
StringUtils.rightPad(null, *) = null StringUtils.rightPad("", 3) = " " StringUtils.rightPad("bat", 3) = "bat" StringUtils.rightPad("bat", 5) = "bat " StringUtils.rightPad("bat", 1) = "bat" StringUtils.rightPad("bat", -1) = "bat"
From source file:tpt.dbweb.cat.io.ConllWriter.java
/** * Format as a table, such that columns are aligned. E.g. * * I (1)/*w ww. j a va 2 s .c o m*/ * want * to * thank * Bill (4 * Daley 4) * exemplary * @param rows * @return */ private static String formatTable(List<List<String>> rows) { List<Integer> width = new ArrayList<>(); // calculate column width rows.forEach(row -> { if (row != null) { while (width.size() < row.size()) { width.add(0); } for (int i = 0; i < row.size(); i++) { width.set(i, Math.max(width.get(i), row.get(i).length())); } } }); // generate output StringBuilder sb = new StringBuilder(); rows.forEach(row -> { if (row != null) { for (int i = 0; i < row.size(); i++) { sb.append(StringUtils.rightPad(StringUtils.defaultString(row.get(i)), width.get(i) + 1)); } } sb.append("\n"); }); return sb.toString(); }
From source file:ubic.basecode.util.r.type.AnovaEffect.java
@Override public String toString() { StringBuilder buf = new StringBuilder(); buf.append(StringUtils.rightPad(StringUtils.abbreviate(getEffectName(), 10), 10) + "\t"); buf.append(String.format("%.2f", getDegreesOfFreedom()) + "\t"); buf.append(String.format("%.4f", getSsQ()) + "\t"); buf.append(String.format("%.4f", getMeanSq()) + "\t"); if (fStatistic != null) { buf.append(StringUtils.rightPad(String.format("%.3f", getFStatistic()), 6) + "\t"); buf.append(String.format("%.3g", getPValue())); }//w w w .j a v a2 s. com return buf.toString(); }