I was expecting the \n to cause the next statement to be printed on a new line but it doesn't...
is my syntax wrong?
writer.printf(" |\t\t\t | Tax Credits\t%010.开发者_运维知识库2f |\n", taxCreds) ;
thanks
Baba
With Java printf
, the newline is a conversion character so you need to use %n
:
%n
: Line separator, the result is the platform-specific line separator
Use %n instead. The API for PrintStream#printf will show this is so. Edit: actually this will direct you to the Formatter API where you will find that %n results in a system-specific new line.
精彩评论