Monday, 15 April 2013

java - String functions - replaceAll not working for "." -


I was going through the replaced all function. I had the following string:

  string str = "com.sac.src.abc.def";  

I had to change all the points with / . So I tried

  str.replaceAll (".", "/" ");  

But what I was getting was my string Changed to -

  ///////////////////////////////////   Div class = "post-text" itemprop = "text"> 

. means "any character." You need to avoid it:

  "\\."  

No comments:

Post a Comment