I have a single string as follows
one two
three
four
I would like to split this into an arrayList so that I can get
String[] g = [one,two,three,four]
I think I need to split by newline and by space but something so simple is defeating me
I have tried:
String [] bilbo=null;
List<String> temp=new ArrayList<String>();
bilbo=g.split("\\n|\\r");
for (String d:bilbo) {
if (d!="") {
if (d.matches("\\s")) {
dd = d.split("\\s");
for (String a : dd) {
temp.add(a.trim());
}
} else {
temp.add(d.trim());
}
}
}