Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #7392

Re: How to join a range of array string slots with blank delimiters? Almost opposite of string.split()?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail
Date Thu, 25 Aug 2011 22:31:27 -0400
From Arne Vajhøj <arne@vajhoej.dk>
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20110812 Thunderbird/6.0
MIME-Version 1.0
Newsgroups comp.lang.java.programmer
Subject Re: How to join a range of array string slots with blank delimiters? Almost opposite of string.split()?
References <4e55dd30$0$7613$9b4e6d93@newsspool1.arcor-online.net> <LuqdnQ3pFovJf8jTnZ2dnUVZ_uOdnZ2d@posted.palinacquisition>
In-Reply-To <LuqdnQ3pFovJf8jTnZ2dnUVZ_uOdnZ2d@posted.palinacquisition>
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
Lines 33
Message-ID <4e57058a$0$312$14726298@news.sunsite.dk> (permalink)
Organization SunSITE.dk - Supporting Open source
NNTP-Posting-Host 72.192.23.157
X-Trace news.sunsite.dk DXC=bBE6dEhW@ORGdO>3\oBM:UYSB=nbEKnk[>7kolSaMc^PJPe3\kP5EUQKBm9cfh9BSTM2;kT<[:>[Q^S[;CaK;HT_9a]bSa[Y;4Q
X-Complaints-To staff@sunsite.dk
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:7392

Show key headers only | View raw


On 8/25/2011 1:49 AM, Peter Duniho wrote:
> On 8/24/11 10:27 PM, Gunter Hansen wrote:
>> Assume I split a text line with a command like:
>>
>> String[] part = line.split("\\s+");
>>
>> Ok, fine, but how is the opposite command?
>> Keep in mind that the delimiter between the joined slots of the target
>> string should be one blank.
>>
>> Moreover: Can I join e.g. only slots [3],...,[MAX]?
>>
>> So I need a command similar to:
>>
>> String joined = part[3,MAX].join(' ');
>>
>> How ca I achieve this?
>>
>> If this is not possible directly then maxbe with a work around?
>
> I am surprised the feature doesn't exist in the JDK; in .NET there's a
> String.Join() method that does exactly what you're asking about. But
> AFAIK, it doesn't.

Even split was just added in 1.4 - before that it was StringTokenizer.

> And I have to admit, I think Java's take on the "split" function is
> pretty cool, what with regex support and all (which .NET doesn't
> provide, not as a String.Split() feature anyway).

.NET has Regex.Split.

Arne

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

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