java - Cannot divide a long string into pieces -


there long string- "sourcemeaning" consists of sentences retrieved sqlitedatabase. used "&" separate sentences below:

sentencea&sentenceb&sentencec ..... 

after long string has been retrieved, string divided to:

sentencea  sentenceb sentencec  .... 

i used string array (meanings) store divided sentences , applied following codes finish task, throws stringindexoutofboundsexception when executing...

string sourcemeaning=c.getstring(1); log.w("sourcemeaning",sourcemeaning); string[] meanings=new string[]{}; int j=0; (int i=0;i<=sourcemeaning.length();i++){     if (sourcemeaning.charat(i)!='&'){         meanings[j]=meanings[j]+sourcemeaning.charat(i);         log.w("translated",meanings[j]);     } else {         j+=1;     } } 

how divide sentences without error?

you should split initial string in way

string sourcemeaning=c.getstring(1); log.w("sourcemeaning",sourcemeaning); string[] meanings = sourcemeaning.split("&"); 

you have in array


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -