Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: Roedy Green 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: Thu, 25 Aug 2011 13:05:22 -0700 Organization: Canadian Mind Products Lines: 31 Message-ID: References: <4e55dd30$0$7613$9b4e6d93@newsspool1.arcor-online.net> Reply-To: Roedy Green NNTP-Posting-Host: RCd/Ul4tyxGUBII8WGwa5g.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 X-Newsreader: Forte Agent 6.00/32.1186 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:7385 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)