I would like to print out a list of items with a row of periods, or ellipsis, between the first text and final variable with a space on each side. So if the spacing is three or more, there should be a period(s) taking place of the spaces in between. I would like to do this inside of a printf, if possible; using Formatting. I know if I put a 0 in front of the width as a flag, then the extra characters will be taken up as zeros, but I'd like the zeros to be as decimal points instead.
Is it possible to do it this way?
Sample Code:
System.out.printf("Egg Count: %9d%n", 300); //list.getNumberOfEggs()
System.out.printf("Chicken Count: %5d%n", 1378); //list.getNumberOfChickens()
System.out.printf("Corn Oil Count: %4d%n", 619); //list.getNumberOfCornOil()
System.out.printf("Orange Count: %6d%n", 2000); //list.getNumberOfOranges()
Sample Output:
Egg Count: 300
Chicken Count: 1378
Corn Oil Count: 619
Orange Count: 2000
Desired Output:
Egg Count: ..... 300
Chicken Count: 1378
Corn Oil Count: 619
Orange Count: . 2000
I found JS - Separating a string with periods to meet certain character length which is somewhat similar, but not what I'm looking for with the use of formatting.
I also found Change the default padding character in Java printf? which can be used for replacing the spaces to demicals, but only if the above printf is split after the colon. This also does not address the spaces to be placed after the colon and before the first digit; perhaps this may be done with Regex/Regular Expressions somehow?