我正在尝试将以下字符串转换为 Java 中的列表,但将其作为单个对象,我需要四个单独的列表对象。
字符串:应用程序“xyz”窗口“abc”的按钮1 应用程序“xyz”窗口“abc”的按钮2 应用程序“xyz”窗口“abc”的按钮3 UI元素1的“完成”按钮应用程序“xyz”的窗口“abc”的滚动区域1
使用的Java代码:
List<String> items = Arrays.asList(resultObject.toString().split("\\s*,\\s*"));
List<String> formattedList = new ArrayList<String>();
for (String item : items) {
formattedList.add(item);
}
预期输出:类似于字符串,但在四个不同的列表对象中
item1 : button 1 of window "abc" of application process "xyz"
item2 :button 2 of window "abc" of application process "xyz"
item3: button 3 of window "abc" of application process "xyz"
item4 :button "Finish" of UI element 1 of scroll area 1 of window "abc" of application process "xyz"