I need to detect a new paragraph with one word from variable which was initialized be reading a text from a web site. For instance, a variable contains (it is printing this way):
hello
Are you sure about...
The resulting string must be
Are you sure about...
I do
String arr[] = message.split("\r");
StringBuilder sb = new StringBuilder();
for (String el: arr) {
String[] temp = el.split(" ");
if(temp.length > 1){
sb.append(el).append("\r");
} else {
continue;
}
}
But for some reason in production it does not do the job so the first word is still present in resultin string. What is the reason?