Is it possible to align text on the center of the command prompt in Java? I don't want to use a fixed number of spaces because it needs to print out a variable that could have a varying amount of characters.
I could use a function to determine how many characters the variable has and print spaces accordingly, but that could change depending on the size of the console window. Is there a cross-OS solution to the problem, or should I just assume a fixed width?