大家好,我有这个字符串:
[JOLLY BLU at STAY SHIP, Voy: 0275/11]
如何在String []
中转换此字符串value[0] = "JOLLY BLU at STAY SHIP";
value[1] = "Voy: 0275/11";
非常感谢
答案 0 :(得分:7)
str = str.substring(1, str.length() - 1); // cut [ and ] off
String[] parts = str.split(",");
答案 1 :(得分:4)
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