大家好,我有这个字符串:
[JOLLY BLU at STAY SHIP, Voy: 0275/11]
如何在String[]中转换此字符串
value[0] = "JOLLY BLU at STAY SHIP";
value[1] = "Voy: 0275/11";
非常感谢
发布于 2012-01-17 05:06:13
str = str.substring(1, str.length() - 1); // cut [ and ] off
String[] parts = str.split(",");
发布于 2012-01-17 05:06:17
String s = "[JOLLY BLU at STAY SHIP, Voy: 0275/11]";
String temp = s.replace("[", "").replace("]", "");
// or String temp = s.substring(1, s.length() - 1);
String[] sArray = temp.split(",");
sArray[1] = sArray[1].trim(); // remove the whitespaces around the string
https://stackoverflow.com/questions/8886237
复制相似问题