avatar image
Former Member

How To Split the String for "."

Hi Friends

I am Using Following Code to Split one String.

String str = "Jeetendra.choudhary";
String[] sp_str = str.split(".");

wdComponentApi.getMessageManager.reportSuccess(str[0]);
wdComponentApi.getMessageManager.reportSuccess(str[1]);

but its throwing null pointer exception.

when i am using following code its working fine.

String str = "Jeetendra/choudhary";
String[] sp_str = str.split("/");

wdComponentApi.getMessageManager.reportSuccess(str[0]);
wdComponentApi.getMessageManager.reportSuccess(str[1]);

what may be the issue and how to split the string with "." ?

Thanks & Regards

Jeetendra

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Dec 29, 2009 at 06:52 AM

    "." is a special character.

    Use

    str.split("\\.");

    Regards

    Benjamin

    Edited by: Benjamin Hansen on Dec 29, 2009 7:52 AM

    Add comment
    10|10000 characters needed characters exceeded

Skip to Content