I currently have a small issue trying to use an if/else statement when a returned string could send me different formats
The issue im having is that when i request a code it either returns a list [1234,122324,21242] a single number [3335] two numbers [332435,34324] or nothing []
Currently im using this code which gives me the second code on teh list, but the issue im having is ive no idea how to take the code if there is only one on the list, or handle if there is nothing returned
String response_body_string = responseBody.body().string();
String[] tmp = response_body_string.split(",");
tmp = tmp[1].split(",");
//Returns second game ID
String val2 = tmp[0];
//Only use 0-9, remove any characters or letters
String val3 = val2.replaceAll("[^0-9]", "");
System.out.println(val3);
//System.out.println(response_body_string);
return val3;
Aucun commentaire:
Enregistrer un commentaire