TextFormatter
class:
/** * Right justify a multi-line String (i.e., a String with embedded * newline characters) in a field of given width. * * If a line is too wide, it is not changed in any way. Otherwise, * spaces are added to the beginning of the line so that it is * exactly width characters wide. * * @param s The multi-line String to justify * @param width The width of the field * @return The justified multi-line String */ public static String flushRight(String s, int width)
/** * Right and left justify a multi-line String (i.e., a String with embedded * newline characters) in a field of given width. * * If a line is too wide, it is not changed in any way. Otherwise, * spaces are added between words so that it is exactly width * characters wide. The number of spaces between words are as * balanced as possible. That is, the added spaces are evenly distributed. * * @param s The multi-line String to justify * @param width The width of the field * @return The justified multi-line String */ public static String flush(String s, int width)
Note: You may choose to add other classes and/or enumerated types.
Copyright 2011