I've a problem with Integer.parseInt(). Specifically my code do this:
serverPort variable is an int correctly initialized to 1910
byte[] multicastMessage = (serverAddress+"::"+String.valueOf(serverPort)).getBytes();
byte[] receivedBytes = receivePacket.getData();
receivedString = new String(receivedBytes, "UTF-8");
String[] decodedString = receivedString.split("::");
serverPort = Integer.parseInt(decodedString[1]);
Note that when I print decodedString[1] in console is correctly printed 1910. But when I call Integer.parseInt() a NumberFormatException is raised.
I've tried also using Integer.toString(serverPort) in first row or using new Integer(decodedString[1]).intValue() in last row without success.
I suspect the conversion issue born using byte (I can't avoid it), but I'm not so familiar with byte struct.
EDIT:
Exception in thread "Thread-0" java.lang.NumberFormatException: For input string: "1910"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at ClientThread.run(ClientThread.java:60)