2

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?

Piccolo
  • 1,612
  • 4
  • 22
  • 38
  • Don't think it is possible if you mean any generic console - http://stackoverflow.com/questions/1286461/can-i-find-the-console-width-with-java – zz3599 Mar 06 '13 at 02:16
  • 2
    @DavidTitarenco - definitely not a duplicate of the linked question. – Perception Mar 06 '13 at 02:46

0 Answers0