android - java splitting textboxes using bufferreader -


hi figuring out how split strings heres code: because using bufferedreader , have 2 textboxes reads both text boxes (the 1st textbox type john), second textbox type peter) output johnpeter trying split textboxes instead of reading 1 line straight.

bufferedreader reader = new bufferedreader(new inputstreamreader(             req.getinputstream()));          string name;      while ((name = reader.readline().tostring()) != null)      {          statement stmt;     string[] players = name.split("");         string playero = players[1];          string playerx = players[2]; 

current output is:

player 1 :j player 2 :o 

i output be:

player 1 :john player 2 :peter 

as is, won't able split string want to, there's no clear delimiting character. if stored "john peter" or "john,peter" or that, easier split.

then need change

string[] players = name.split("");

to string[] players = name.split(" ");

or string[] players = name.split(",");

also, others have mentioned, remember first item in players players[0], not players[1]


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -