Reputation: 22076
I need to split string with delimiter of \n
when I use this code:
String delimiter = "\n";
String[] temp;
temp = description2[position].split(delimiter);
for (int i = 0; i < temp.length; i++) {
holder.weeklyparty_text3.setSingleLine(false);
holder.weeklyparty_text3.setText(temp[i]);
}
but not get split string from \n
.
Upvotes: 0
Views: 4971
Reputation: 1366
In order to support Unix and Windows new lines use:
String lines[] = String.split("\r?\n");
as described in:
Upvotes: 0
Reputation: 3748
Split uses regex - so to split on a newline, you should use:
String delimiter = "\\n";
Upvotes: 0