- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
// gotta love this hack
final private static String PADDING =
" ";
private static String stringFormat(String stringToFormat, int fieldSize, boolean rightJustify) {
// and Java doesn't really excel at this kind of thing either
if (stringToFormat.length() >= fieldSize) {
return stringToFormat.substring(0, fieldSize);
} else {
return rightJustify ?
PADDING.substring(0, fieldSize - stringToFormat.length()) + stringToFormat:
stringToFormat + PADDING.substring(0, fieldSize - stringToFormat.length());
}
}
Lure Of Chaos 21.12.2010 17:25 # +3
FadedInto 22.12.2010 00:55 # +1
fieldSize > stringToFormat.length() + PADDING.length()
остальное не ГК.
Lure Of Chaos 22.12.2010 01:11 # 0
FadedInto 22.12.2010 01:26 # 0