如何将字符串作为请求发送到服务器?得到响应后,我应该再次将字符串分成几部分。我在这里将ArrayList
存储到字符串中:
ArrayList<String> contactlist=new ArrayList<String>();
contactlist.add("Android");
contactlist.add("tarnaka");
contactlist.add("uppal");
contactlist.add("Prasad");
String[] contact=new String[contactlist.size()];
contact=contactlist.toArray(contact);
最佳答案
你在这里
ArrayList<String> contactlist = new ArrayList<String>();
contactlist.add("Android");
contactlist.add("tarnaka");
contactlist.add("uppal");
contactlist.add("Prasad");
StringBuffer sb = new StringBuffer("");
for (String temp : contactlist) {
sb.append("-" + temp);
}
String stringToSend = sb.toString();
MyLog.printLog("String : " + stringToSend);
String[] rString = stringToSend.split("-");
for (String s : rString) {
MyLog.printLog("Names : " + s);
}