I have a code in Java that is meant to get the server info from a Minecraft server. This returns data split by §. In eclipse, when run as an application, the code works fine. The issue is when I bring it to Android. I have done some research on this but haven't been able to find a working solution. (Have tried Pattern.quote("§")) Here is an example of what I'm running:
String input = "Look like this§0§25";
String[] data = input.split("§");
The expected data would be a 3-long String[] with the values "Look like this", "0", and "25". This is what happens in eclipse. In android, I get a 1-long String[] with the value "Look like this§0§25". Does anyone know if this is an issue with android or am I doing something wrong?
It is clearly an encoding issue. I copied the string directly from your question and pasted in Android Studio. Then, run this code segment:
The output was what you ask:
Alternatively, you may use StringTokenizer as follows:
However, if you do not match the character codes properly, both methods will not work.