Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

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

Former Member
Former Member replied

"." is a special character.

Use

str.split("\\.");

Regards

Benjamin

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

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question