String url="http://someexample.com/?cid=cid123 &club_id=club123&s4c=10&dom=someexample.com&hash=testhash";
String[] params = url.split("&");  
for (String param : params)  {  
    String name = param.split("=")[0];  
    String value = param.split("=")[1];  
    System.out.println(name+":"+value);
}  
It displays Output
http://someexample.com/?cid:cid123
club_id:club123
s4c:10
dom:someexample.com
hash:testhash
But I want to get cid as well so I tried the following
    String delimeter1="?";
    String delimeter2="&";
    url=url.replace(delimeter1, delimeter2);
And when I ran the program it gave me following error
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
Please suggest me what I am doing wrong here ?
 
     
     
    