Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static ClientMessage parseMessage(char[] msg) {
- // Is there a colon within the char array?
- int indexOfColon = CharacterArrayUtil.indexOfChar(msg, 0, msg.length, ':');
- if (indexOfColon != -1) {
- // There is a body to be parsed!
- String header = new String(msg, 0, indexOfColon);
- char[] body = CharacterArrayUtil.chompArray(msg, indexOfColon + 1, msg.length);
- return new ClientMessage(header, body);
- }
- else {
- // There isn't any body to be parsed.
- return new ClientMessage(new String(data), null);
- }
- }
Add Comment
Please, Sign In to add comment