BlackBerry Forums Support Community
              

Closed Thread
 
LinkBack Thread Tools
Old 05-05-2011, 12:53 PM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Apr 2010
Model: 8520
PIN: N/A
Carrier: T-Mobile
Posts: 25
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default String.split()

Please Login to Remove!

Why string.split() is not available in BB sdk? any other way to split a string and allocate it to an array

ex. array = string.split(" ");
Offline  
Old 05-08-2011, 11:14 AM   #2 (permalink)
New Member
 
Join Date: May 2011
Model: 7100T
PIN: N/A
Carrier: wtf
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: String.split()

Because it isn't part of JavaME. You can just implement your own like shown below. To call it, use something like "String[] array = split(originalString, separartor)".

Code:
    private String[] split(String original, String separator) {
        Vector nodes = new Vector();
        int index = original.indexOf(separator);
        while (index >= 0) {
            nodes.addElement(original.substring(0, index));
            original = original.substring(index + separator.length());
            index = original.indexOf(separator);
        }
        nodes.addElement(original);
        String[] result = new String[nodes.size()];
        if (nodes.size() > 0) {
            for (int loop = 0; loop < nodes.size(); loop++) {
                result[loop] = (String) nodes.elementAt(loop);
                System.out.println(result[loop]);
            }
        }
        return result;
    }
Offline  
Closed Thread


Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads for: String.split()
Thread Thread Starter Forum Replies Last Post
String.Split - ? DD12 Developer Forum 2 03-30-2009 11:12 AM

Keystone 00014 - KTEB-226-1-TP Compact Fluorescent Ballast
$24.76
Keystone 00014 - KTEB-226-1-TP Compact Fluorescent Ballast pictureNEW - POWER LIGHTING PRODUCTS 120V 60HZ BALLAST Prime 8G1024W Ultra-Miser
$44.99
NEW - POWER LIGHTING PRODUCTS 120V 60HZ BALLAST Prime 8G1024W Ultra-Miser pictureNEW IN BOX POWER LIGHTING PRODUCTS 120V 60HZ BALLAST 8G1024W Ultra-Miser
$44.99
NEW IN BOX POWER LIGHTING PRODUCTS 120V 60HZ BALLAST 8G1024W Ultra-Miser pictureICN-1P32-N ADVANCE CENTIUM BALLAST 1 LAMP120-277 PHILIPS
$5.99
ICN-1P32-N ADVANCE CENTIUM BALLAST 1 LAMP120-277 PHILIPS pictureKEYSTONE KTEB-132LBF-UV-TP-PIC /B FLUORECENT LIGHT BALLAST
$5.99
KEYSTONE KTEB-132LBF-UV-TP-PIC /B FLUORECENT LIGHT BALLAST picture






Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.