#String Formatting

1 messages · Page 1 of 1 (latest)

sick junco
#

This one's been bugging me for a while, using printf to write to a file. Basically there's two string values let's say stringOne and stringTwo. Im trying to format it something like stringOne ===> stringTwo. There are many iterations of these values and a few of these are not lined up properly column wise.

sharp plumeBOT
#

<@&987246399047479336> please have a look, thanks.

sharp plumeBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

sick junco
#

printWriter.printf("%-41s %-10s Base.%-37s\n",itemPair.get(1),"==>",itemPair.get(0));

#

btw i got the max length possible for stringOne and stringTwo, that's why using 37 and 41 here.

#

this is the output im getting, notice the item "Baking Tray"

sick junco
keen ocean
sick junco
#

before as in? for category and stuff?

keen ocean
#

at the left

#

why are there spaces

#

why are there indentation

sick junco
#

im not sure, ill verify the map to see if all the strings are without any space.

keen ocean
#

also, why are you using %-10s for "==>" ? it's always the same value

sick junco
#

ye i was experimenting with max length stuff in printf, so changed it like that.

#

oki i think i see the problem, i can see the extra space in my arraylist. Ill work with that.

sick junco