Guest User

Untitled

a guest
Jun 22nd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. public static ClientMessage parseMessage(char[] msg) {
  2.  
  3. // Is there a colon within the char array?
  4. int indexOfColon = CharacterArrayUtil.indexOfChar(msg, 0, msg.length, ':');
  5.  
  6. if (indexOfColon != -1) {
  7.  
  8. // There is a body to be parsed!
  9. String header = new String(msg, 0, indexOfColon);
  10. char[] body = CharacterArrayUtil.chompArray(msg, indexOfColon + 1, msg.length);
  11.  
  12. return new ClientMessage(header, body);
  13. }
  14. else {
  15.  
  16. // There isn't any body to be parsed.
  17. return new ClientMessage(new String(data), null);
  18. }
  19. }
Add Comment
Please, Sign In to add comment