> I need to print table to console.
> Before output text to cell I need to set text width
> and justification. How to do it in java 1.4.
>
> In 1.5 I'd use printf().
There's no such functionality in 1.4. You'll have to roll your own.
public class Main {
static String myPrintf(String str, int width, char fill) {
StringBuffer b = new StringBuffer();
while((width--)-str.length() > 0) {
b.append(fill);
}
b.append(str);
return b.toString();
}
public static void main(String[] args) {
System.out.println("["+myPrintf("abc", 10, ' ')+"]");
}
}