yitzih
yitzih

Reputation: 3118

Using "\n" in a Formatter Object

I am trying to format date to be output to a file. However I want the data to be easily readable in the file itself. Each line should have a single account with the account# the persons name and their balance but the following code doesn't print each one on a separate line. Another issue I am having is that it is not outputting with only 2 decimal places even though I am using %.2f

outNewMaster.format("%d %s %s %.2f\n", acc.getAccount(), acc.getFirstName(), acc.getLastName(), acc.getBalance());

Upvotes: 0

Views: 65

Answers (1)

Marcus Widegren
Marcus Widegren

Reputation: 540

Newline in a format string is

%n

So try that. :)

Upvotes: 1

Related Questions