code to devide a String into different parts based on given symbol (eg:':').. in Android

String str = "FN:FreddyLn:LunoCaseType:1TicketNumber:1216-gg-14169CaseID:2";
        StringTokenizer st = new StringTokenizer(str, ":");
        System.out.println("Tokens Count:  " + st.countTokens());
        String arrayString[]=new String[st.countTokens()];
        String ticketNumbr=null,caseId=null;
        int tokenCount=st.countTokens();
        for(int i=0;i<tokenCount;i++)
        {
            arrayString[i]=st.nextToken();
           
            if(i==tokenCount-2){
                ticketNumbr=arrayString[i];
             System.out.println("TicketNumber:  " + ticketNumbr);
            }
            caseId=arrayString[i];           
        }
        System.out.println("CaseId:  " + caseId);
        int StrLength=ticketNumbr.length();
        String subString=ticketNumbr.substring(0, StrLength-6);
        System.out.println("TicketNumber :  " + subString);

Comments

Popular posts from this blog

Custom Dialog with no title and full screen in Android

Best working code to set Date limits on Date Picker Dialog,in Android

code to display .pdf,.text,.DOC,.DOCX,.doc extension files exists in SDCard