我从txt文件中读取了一行。 我如何解析这一行:
shop "The best shop" "2006"
到字符串数组?
例如:
array[0] = [shop]
array[1] = [The best shop]
array[2] = [2006]
没有双引号和空格?
答案 0 :(得分:0)
String shop = "shop \"The best shop\" \"2006\"";
String[] tokens = shop.split(" \"");
for (int i = 0; i < tokens.length; i++) {
tokens[i] = tokens[i].replace("\"", "");
System.out.println("array[" + i + "] = [" + tokens[i] + "]");
}
但这仅适用于此行:)