Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #7385
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: How to join a range of array string slots with blank delimiters? Almost opposite of string.split()? |
| Date | 2011-08-25 13:05 -0700 |
| Organization | Canadian Mind Products |
| Message-ID | <g8ad5719168sakagkf0cabsrof0s8f5v1n@4ax.com> (permalink) |
| References | <4e55dd30$0$7613$9b4e6d93@newsspool1.arcor-online.net> |
On 25 Aug 2011 05:27:12 GMT, GHansen@hotmail.com (Gunter Hansen)
wrote, quoted or indirectly quoted someone who said :
>
>If this is not possible directly then maxbe with a work around?
I would do it like this:
final FastCat sb = new FastCat ( slots.length * 2 - 1 );
for ( String slot ; slots )
{
if( sb.length() != 0 )
{
sb.append( ' ' );
}
sb.append( slot );
}
final String joined = sb.toString();
see http://mindprod.com/products1.html#FASTCAT
Alternatively you could compute the final string length and allocate a
char[]. Then plop the pieces in, and convert to a string, which is
roughly what FastCat does under the hood.
--
Roedy Green Canadian Mind Products
http://mindprod.com
The modern conservative is engaged in one of man's oldest exercises in moral philosophy; that is,
the search for a superior moral justification for selfishness.
~ John Kenneth Galbraith (born: 1908-10-15 died: 2006-04-29 at age: 97)
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
How to join a range of array string slots with blank delimiters? Almost opposite of string.split()? GHansen@hotmail.com (Gunter Hansen) - 2011-08-25 05:27 +0000
Re: How to join a range of array string slots with blank delimiters? Almost opposite of string.split()? Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-08-24 22:49 -0700
回复:Re: How to join a range of array string slots with blank delimiters? Almost opposite of string.split()? Yuxuan Wang <crnlmcn@gmail.com> - 2011-08-24 23:42 -0700
Re: How to join a range of array string slots with blank delimiters? Almost opposite of string.split()? Arne Vajhøj <arne@vajhoej.dk> - 2011-08-25 22:31 -0400
Re: How to join a range of array string slots with blank delimiters? Almost opposite of string.split()? Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-08-25 20:15 -0700
Re: How to join a range of array string slots with blank delimiters? Almost opposite of string.split()? Roedy Green <see_website@mindprod.com.invalid> - 2011-08-25 13:05 -0700
Re: How to join a range of array string slots with blank delimiters? Almost opposite of string.split()? Roedy Green <see_website@mindprod.com.invalid> - 2011-08-31 23:41 -0700
Re: How to join a range of array string slots with blank delimiters? Almost opposite of string.split()? Arne Vajhøj <arne@vajhoej.dk> - 2011-08-25 22:28 -0400
csiph-web