What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Space words out in JAVA?

Space words out in JAVA?
Author: Message:
albert
Veteran Member
*****

Avatar

Posts: 2247
Reputation: 42
– / Male / Flag
Joined: Feb 2005
O.P. Undecided  Space words out in JAVA?
hey guys I'm searching for a way to actually justify a text by coding it.

what i did until now is find how many caracters are written.. then i got 80 which is the maximum there should be and did

80 - number of caracthers present
replaced all ponctuation by spaces
trimmed the string so no spaces are before or after text
counted how many spaces
divided numbers of spaces left by the number of spaces there is

now i just want to know how i could add spaces between the words.
I can't seem to find a way..

:S
12-10-2006 01:36 AM
Profile E-Mail PM Web Find Quote Report
foaly
Senior Member
****

Avatar

Posts: 718
Reputation: 20
38 / Male / Flag
Joined: Jul 2006
RE: Space words out in JAVA?
I'm not really understanding what you want...
you have a string off words... between the words are spaces and you want to add spaces?
couldn't you just do something like:

code:
String s="the string";
int i=0;
while(i>-1&&i<s.length){
   i=s.IndexOf(" ",i);
   String temp1 = s.substring(0,i);
   String temp2 = s.substring(i,s.length);
   temp1 +=" ";
   s= temp1+temp2
}

or something like that?

This post was edited on 12-10-2006 at 04:06 PM by foaly.
12-10-2006 04:05 PM
Profile E-Mail PM Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: Space words out in JAVA?
quote:
Originally posted by alby
hey guys I'm searching for a way to actually justify a text by coding it.
Where are you writing the text to?
[Image: spartaafk.png]
12-10-2006 07:24 PM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On