Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 3.00 average.
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-04-2005, 03:49 AM   PM User | #1
Bobbo171
Regular Coder

 
Join Date: Aug 2004
Posts: 111
Thanks: 0
Thanked 0 Times in 0 Posts
Bobbo171 is an unknown quantity at this point
java equivalent to php explode

What function in java is equivalent to the php explode function?
Bobbo171 is offline   Reply With Quote
Old 05-04-2005, 06:04 PM   PM User | #2
suryad
Regular Coder

 
Join Date: Apr 2005
Location: Folsom, CA
Posts: 115
Thanks: 0
Thanked 0 Times in 0 Posts
suryad is an unknown quantity at this point
I am gonna go ahead and assume you are working with server-side programming in JAva maybe? Are you using Servlets or JSPs? I worked with Servlets before and learning JSPs right now so I might be able to help if you could describe the functionality of explde in PHP.
suryad is offline   Reply With Quote
Old 05-04-2005, 06:05 PM   PM User | #3
suryad
Regular Coder

 
Join Date: Apr 2005
Location: Folsom, CA
Posts: 115
Thanks: 0
Thanked 0 Times in 0 Posts
suryad is an unknown quantity at this point
Hey I just did a simple google search and found maybe what you are looking for would be the StringTokenizer class or the split method in the String class. That would be my suggestion if I am not waaaaaaaaaaaaay off of what you are asking. CHeers!
suryad is offline   Reply With Quote
Old 05-04-2005, 06:22 PM   PM User | #4
shmoove
Regular Coder

 
Join Date: Dec 2003
Posts: 367
Thanks: 0
Thanked 0 Times in 0 Posts
shmoove is an unknown quantity at this point
Yup, String.split() will probably do (it doesn't have the limit optional parameter).

Java Tip: You need to do something with strings, look for classes that have "string" in their name.

shmoove
shmoove is offline   Reply With Quote
Old 02-04-2008, 04:52 PM   PM User | #5
Sime
New to the CF scene

 
Join Date: Feb 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Sime is an unknown quantity at this point
split is similar

String str = "Madrid,Paris,London";
String[] tokens = str.split(",")

-------------------------------------

tokens[0] = "Madrid";
tokens[1] = "Paris";
tokens[2] = "London";

-------------------------------------
Sime is offline   Reply With Quote
Old 06-14-2010, 11:44 PM   PM User | #6
deathcorvette
New to the CF scene

 
Join Date: Jun 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
deathcorvette is an unknown quantity at this point
Use org.apache.commons.lang.StringUtils

The problem with String.split() is that it uses a greedy regex match, so if some of your tokens are empty strings, it will drop them. If you want to preserve empty strings, use this method:

StringUtils.splitPreserveAllTokens(String str, char separatorChar)
deathcorvette is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:36 PM.


Advertisement
Log in to turn off these ads.