I got a string, which I am trying to split up.
The string looks like
50.5|70|10 and I am trying to get the different parts into different text fields.
String slices = getSettings().split("|"); part_diameterTextField.setText(slices); part_lengthTextField.setText(slices); pin_diameterTextField.setText(slices);
I had expected this to put 50.5 into part_diameter, 70 into part_length, and 10 into pin_diameter, but instead I get nothing in part_diameter, 5 in part_length, and 0 in pin_diameter.
Am I doing the splitting wrong somehow?
Ah… Apparently, using | does not work properly, but using ; works just fine.
Thanks for the update, I am glad you resolved the issue.
Keep in mind that split() parameter is not just set of characters, it’s actually java regular expression. Some special characters have to be escaped to make it work. In this case you should use
String slices = getSettings().split("\\|");