开发者

java program to make a space inside a string having continuous dots('...')

I had a problem in a jsp page in which there is a string inside a column like (abdur...rahman) .because of this cont开发者_开发问答inuous dots inside a string, I am not able to wordwrap that string, so it exceeds the column.

In java how can I solve this problem,it should not use "println" stmt to return. It should use some other function to return since it will be used for jsp page.


I'm not sure what you want, but I can try to help:

You can use printf:

System.out.printf("%10s%10x%10s\n", string1, string2, string3);

And if you add a minus (-) before the 10, the text is aligned the other side of the column:

System.out.printf("%-10s%-10x%-10s\n", string1, string2, string3);


If you want to replace dots with space char or something else you can use java.util.StringTokenizer to generate tokens (By default deliminators are space, carriage returns. You can cretae your own), replace function can replace these dots with other char. Split() function will split it.

You can use it in JSP pages like this example : Rakesh Blog String Manipulation


Add \t between two column

out.println(\t\t+"column1"+\t\t+"column2");

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜