0

I had a problem in a jsp page in which there is a string inside a column like (abdur...rahman) .because of this continuous 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.

Adnan
  • 25,882
  • 18
  • 81
  • 110
Abdur Rahman
  • 11
  • 1
  • 3
  • Do you want to remove the dots and compress the string? – lobster1234 Apr 22 '11 at 09:13
  • Either it's homework, or it's plain sad ignorance. In both cases, the answer is not in StackOverflow, but in JDK doc for the String class (take a look at these strange `replace` methods). – Riduidel Apr 22 '11 at 09:13
  • See also [Insert ellipsis (…) into HTML tag if content too wide](http://stackoverflow.com/questions/536814/insert-ellipsis-into-html-tag-if-content-too-wide). – trashgod Apr 22 '11 at 11:26

3 Answers3

0

Add \t between two column

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

prolink007
  • 33,872
  • 24
  • 117
  • 185
jayesh
  • 2,422
  • 7
  • 44
  • 78
0

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);
Martijn Courteaux
  • 67,591
  • 47
  • 198
  • 287
0

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