2 Replies - 1394 Views - Last Post: 19 October 2011 - 11:25 AM Rate Topic: -----

#1 sangkaran  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 19-October 11

splitting a string into separate strings

Posted 19 October 2011 - 11:05 AM

write a program to splitting a string into separate string based on a delimiter character.
for example: suppose you have a string with the parts of an address separated by colons, like this:
591.TS/2/11 Third Street: in: Kedah: 06000.
with the split method, you can easily separate this string into four string. in the process, the colons are discard.
Is This A Good Question/Topic? 0
  • +

Replies To: splitting a string into separate strings

#2 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2198
  • View blog
  • Posts: 5,226
  • Joined: 10-September 10

Re: splitting a string into separate strings

Posted 19 October 2011 - 11:20 AM

Look at the method String.split().

Look at the method String.split().
Was This Post Helpful? 0
  • +
  • -

#3 lifeinbinary  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 158
  • Joined: 15-February 11

Re: splitting a string into separate strings

Posted 19 October 2011 - 11:25 AM

Try:

<code>StringTonizer st = new StringTokenizer( yourString, ": ");

String firstString = st.nextToken();</code>

Try:

<code>StringTonizer st = new StringTokenizer( yourString, ": ");

String firstString = st.nextToken();</code>

oops... I mean:

StringTonizer st = new StringTokenizer( yourString, ": ");

String firstString = st.nextToken();


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1