1

I'm making a basic program and centering the text would really help with organization. I don't really expect this to be possible but it's worth asking.

Tried:

  1. Using StringUtils, doesn't work because java.lang doesn't have it, I think.
  2. padding the text with spaces, too much work for all the text I'm returning.

Any ideas? I know it's terminal and I should probably be using something else to make it look nicer.

Infinite Recursion
  • 6,511
  • 28
  • 39
  • 51
Howcan
  • 313
  • 3
  • 5
  • 16
  • Show us what you have tried so far. An example of the expected output would help too. – reto Dec 04 '13 at 08:08
  • take a look at this: http://stackoverflow.com/questions/12793593/how-to-align-string-on-console-output – kai Dec 04 '13 at 08:09
  • It's just centering a string I need to return. The format() method seems to be the solution, thank you. – Howcan Dec 04 '13 at 08:11
  • @Howcan Welcome to SO. If an answer worked for you, you should accept it so that the question is marked "answered" and the person helping you gets his reputation points. You will find more info here: http://stackoverflow.com/about – DeltaLima Dec 04 '13 at 08:29

1 Answers1

0

Use System.out.format instead of System.out.println

Also, you can use Formatter, in Java documentation:

This class provides support for layout justification and alignment, common formats for numeric, string, and date/time data, and locale-specific output.

Infinite Recursion
  • 6,511
  • 28
  • 39
  • 51