I have a .txt text file, containing some lines.. I load the contain using the RequestBuilder object, and split the responseText with words = String.split("\n"); but i wonder, why the result is contains the "\n" part.. For example, my text:
abc
def
ghi
the result is,
words[0] = "abc\n"
words[1] = "def\n"
words[2] = "ghi\n"
Any help is highly appreciated. Thanks in advance.
Try using string.split("\\n+")
. Or even better - split("[\\r\\n]+")
You may also want to consider String[] lines = text.split("\\\\n");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With