I have a string containing many words.
The words has to be displayed based on the positions.
Example,
String str = "Australia Canberra Adellide ";
The above string should be,
Australia should start at 0 and end at 20
Canberra should start at 20 and end at 30
Adellide should start at 30 and end at 50
This i will be displaying in a jtextarea
Are there any formatter available in java? or padding should be used?
You can pad strings with
String.format()with the%-nsformat specifier.If you want to intersperse letters between individual letters, your best bet is probably a simple regular expression (i.e.,
s.replaceAll(".", "$0 ")).