I think my fault is line23.
String sub = s.substring(0,s.indexOf(" "));
But i don't know how to solve it. Please help me.