title: Split a string in Java
body: <p>I have a function that accepts a message in String form. The message looks like this : "HTTP/1.1 GET /1/ \n"</p>
  
  <p>I have been using the java.String.split method to break down the string into three smaller substrings, version, command, and number. Then I reconstruct the oringal string from the substrings and output it.</p>
  
  <p>However, when I run teh function the program results in ArrayIndex out of bounds : 1, but still functions properly. But when I run the program step by step in the debugger (netbeans) the program does not result in the ArrayIndex out of bounds nonesense and functions as normal</p>
  
  <p>Any suggestions?</p>
  
  <p>Sam</p>
  
  <pre><code>String output = "";
  
          String[] tokens = clientMessage.split(" ");
          String version = tokens[0];
          String command = tokens[1];
          String potNum = tokens[2];
          output = version + " " + command + " " + potNum;
  </code></pre>
  
  <p>EDIT yes, the program is multithreaded, the clientMsessage string contains "HTTP/1.1 GET /1/ \n" all the time, the value fo clientMessage never changes. The clientMessage is a string sent from a client program and then processed on the server and the output is snet back tot eh client but I keep getting the array errors</p>