(String text, int width)
| 227 | } |
| 228 | |
| 229 | private String pad(String text, int width) { |
| 230 | if(text.length() == width) { |
| 231 | return text; |
| 232 | } |
| 233 | else if(text.length() > width) { |
| 234 | return text.substring(0, width); |
| 235 | } |
| 236 | else { |
| 237 | StringBuilder padded = new StringBuilder(text); |
| 238 | while(padded.length() < width) { |
| 239 | padded.append(' '); |
| 240 | } |
| 241 | return padded.toString(); |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | private int lengthOfLongestStringIn(Collection<String> descriptions) { |
| 246 | int result = 0; |