Here you can find the source of formatSeperatorRow(int[] sizes)
Parameter | Description |
---|---|
sizes | the sizes |
public static String formatSeperatorRow(int[] sizes)
//package com.java2s; public class Main { private static final String SPACES = " "; private static final String DASHES = "------------------------------------------------"; /**/*from w ww .j av a 2s . com*/ * Format seperator row. * * @param sizes * the sizes * * @return the string */ public static String formatSeperatorRow(int[] sizes) { String[] values = new String[sizes.length]; for (int i = 0; i < values.length; i++) { values[i] = DASHES; } return formatRow(" ", values, sizes); } /** * Format row. * * @param values * the values * @param sizes * the sizes * * @return the string */ public static String formatRow(String[] values, int[] sizes) { return formatRow(" ", values, sizes); } /** * Format row. * * @param prefix * the prefix * @param values * the values * @param sizes * the sizes * * @return the string */ public static String formatRow(String prefix, String[] values, int[] sizes) { StringBuffer sb = new StringBuffer(); sb.append(prefix); for (int i = 0; i < sizes.length; i++) { if (i != 0) { sb.append(" "); } sb.append(fixLength(values[i], sizes[i])); } return sb.toString(); } /** * Fix length. * * @param str * the str * @param len * the len * * @return the string */ public static String fixLength(String str, int len) { if (str != null) { str = str + SPACES; } else { str = SPACES; } return str.substring(0, len); } }