Reputation: 141
I am trying to split a string, but it doesn't work. I debugged my app and I found that the problem was occurring on line 8. On line 8 it shows a document which is named pattern.class
& the app stopped working. I can't see any problem in my code; I have just followed the rules.
How can I resolve this?
My code:
String AdsIds[]=new String[6];
String EnTitle[]=new String[6];
String AdsTemproryData[]=new String[6];
String BineryTemprory[]=new String[2];
public void sieve(String Hash){
AdsTemproryData=Hash.split("/");
for(int i=0;i<=5;i++){
BineryTemprory= AdsTemproryData[i].split("*");
AdsIds[i]=BineryTemprory[0];
EnTitle[i]=BineryTemprory[1];
}
Upvotes: 0
Views: 141
Reputation: 2950
You need to escape the asterisk:
split(\\*)
So your code will be:
String AdsIds[]=new String[6];
String EnTitle[]=new String[6];
String AdsTemproryData[]=new String[6];
String BineryTemprory[]=new String[2];
public void sieve(String Hash){
AdsTemproryData=Hash.split("/");
for(int i=0;i<=5;i++){
BineryTemprory= AdsTemproryData[i].split("\\*");
AdsIds[i]=BineryTemprory[0];
EnTitle[i]=BineryTemprory[1];
}
Upvotes: 7