java printf with repeating periods -
we can use space pad output fit "fixed width columns" in java using printf. example:
system.out.printf("%-30s - %s%n", "hello hello", "goodbye goodbye"); system.out.printf("%-30s - %s%n", "lots of cats", "large amounts of dogs"); system.out.printf("%-30s - %s%n", "a crowd of teachers", "no students"); system.out.printf("%-30s - %s%n", "three desks", "twenty boxes");
gives output
hello hello - goodbye goodbye lots of cats - large amounts of dogs crowd of teachers - no students 3 desks - twenty boxes
what achieve this:
hello hello. . . . . . . . . . . goodbye goodbye lots of cats . . . . . . . . . . large amounts of dogs crowd of teachers. . . . . . . no students 3 desks. . . . . . . . . . . twenty boxes
or
hello hello..................... goodbye goodbye lots of cats.................... large amounts of dogs crowd of teachers............. no students 3 desks..................... twenty boxes
looks has been attempted before change default padding character in java-printf. workaround suggested , may fit scenario, although maybe modify java sourcecode, think advise against that.
Comments
Post a Comment