I'm trying to split each object in the ArrayList because a lot of lines contains comma(","). Each object contains a item and value(but not all objects contains value):
Access control enable ,disabled
Access policy prototyping ,enabled
Access user group
Implicit roles access policy
World access policy ,disabled
This is my piece of code:
List<String> CEP = new ArrayList<String>();
List<String> CEV = new ArrayList<String>();
for (String str : CE) {
for (String s : str.split(",")) {
CEP.add(s.trim());
}
}
- "CE" is the main ArrayList.
- "CEP" is the ArrayList that should contain only the "items"(what before comma).
- "CEV" is the ArrayList that should contain all "values"
My piece of code only split it by comma to the same ArrayList and another problem is how to see an object doesn't have "value" and add blank to the values ArrayList.
Thanks guys.