java - Group concatenated strings by 160 characters per group and do the same thing on the remaining -


i have table want data retrieved. managed retrieve these datas. twist want concatenate these data (which of strings) create string 160 characters. managed having code answered guy here in stackoverflow.

the code this:

list<pending> pending = db.getallpending();     string = "";     (pending pn : pending) {        if (a.length() + pn.getpm_str().length() <= 160) {     += pn.getpm_str();     }     else     break;     }  

the code concatenates data until has formed 160 length string. disregard other data happened exceed limit.

my problem is: how going same thing remaining data list (which not included in first batch of 160 length string)? want these data concatenated create same.

the concept of program has sms sending. data concatenated , group 1 sms sent.

need help.

you need create list of resulting strings , add when concatenated string reaches limit:

list<pending> pending = db.getallpending(); list<string> resultingstrings = new arraylist<string>(); string = ""; (pending pn : pending) {    if (a.length() + pn.getpm_str().length() <= 160) {         += pn.getpm_str();    }    else {         resultingstrings.add(a);         = pn.getpm_str();    } }  resultingstrings.add(a); 

Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -