×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    12

    Unhappy Urgent help needed with multidimensional arrays.......

    i want to write a function which accepts the stream which looks some wat like this....

    PERMISSIONS:TRUE,TRUE|ENTITIES PERMITTED,AB,ABCD,EF,EFGH,IJ,IJKL|FETCHING DETAILS,201.100.3.2,301,201.100.3.3,309|


    and i want to make a 2 dimensional array which holds the splitted feilds.....

    structure of function needed is is as follows....


    public String spliter(String stream,String eot/*|*/,String coma/*,*/,String feild)
    {
    }



    any bright mind pls help me its urgent..............

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Urgent help needed with multidimensional arrays.......

    I'm afraid you will need to write a String splitting method. Sadly, the StringTokenizer class does not exist in CLDC.

    I'd suggest you start by writing a method like:

    Code:
    public static String[] split(String input, char delimiter) {
    }
    Then you can split the entire string with '|' as the delimiter, then split the individual strings returned by that, using ',' as the delimiter. This will be easier than trying to do the entire job in one go.

    The methods String.indexOf() and String.substring() should be helpful.

    Graham.

  3. #3
    Registered User
    Join Date
    Feb 2010
    Posts
    12

    Red face Re: Urgent help needed with multidimensional arrays.......

    Quote Originally Posted by grahamhughes View Post
    I'm afraid you will need to write a String splitting method. Sadly, the StringTokenizer class does not exist in CLDC.

    I'd suggest you start by writing a method like:

    Code:
    public static String[] split(String input, char delimiter) {
    }
    Then you can split the entire string with '|' as the delimiter, then split the individual strings returned by that, using ',' as the delimiter. This will be easier than trying to do the entire job in one go.

    The methods String.indexOf() and String.substring() should be helpful.

    Graham.

    thnx a lot man i know this is the onl;y thing i could do but i dont have time to indulge my self on this module m forced to complete my project on time if any one out there who can code this method for me i would be thankfull.....

  4. #4
    Registered User
    Join Date
    Feb 2010
    Posts
    12

    Re: Urgent help needed with multidimensional arrays.......

    i have already tried those methods still if any one around could contribute to this it would be great help!

  5. #5
    Registered User
    Join Date
    May 2007
    Posts
    91

    Re: Urgent help needed with multidimensional arrays.......

    Hello,
    You can use below method for your purpose.

    Code:
    	public static String[] parser(String splitStr, String delimiter) {
               try{
    		Vector vc = new Vector();
    		int index=0;
    		
    		while((index=splitStr.indexOf(delimiter))!=-1) {
    			vc.addElement(splitStr.substring(0,index));
    			splitStr=splitStr.substring(index+1);
    		}
    		vc.addElement(splitStr.substring(index+1));
    		//convert the vector into an array
    	    String[] splitArray = new String[vc.size()];
    	    for (int i=0; i < splitArray.length; i++) {
    	        splitArray[i] = ""+vc.elementAt(i);
    	    }
    		return splitArray;
                    
             }catch(Exception e){
                
                 System.out.println("Exception in Tokenizer: parser -> "+e);            
                 return new String[1];
             }
    	}



    Amit

Similar Threads

  1. Urgent help needed in choicegroup.popup
    By knights123 in forum Mobile Java General
    Replies: 5
    Last Post: 2009-07-29, 06:20
  2. Urgent Help Needed For a Application
    By damithark in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2009-06-24, 10:12
  3. icons no displayed in column list box urgent help needed.
    By Rajani_sp in forum Symbian User Interface
    Replies: 0
    Last Post: 2007-11-20, 11:49
  4. Experts view is needed ....urgent!!
    By imran712 in forum Mobile Java General
    Replies: 0
    Last Post: 2005-06-01, 21:42
  5. Urgent help needed !!!!!
    By daquietmonkey in forum Mobile Java General
    Replies: 1
    Last Post: 2002-08-28, 08:28

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×