Is there a way in Java
in which I can split
a string into an array, but with the delimiter
? For example normally I would have a String
such as this in the text editor I am building:
String content = "What time\nWhat day\nWhat month\n\n\nAsdf"
And if I called the split
method with the \n delimiter
like this:
content.split("\n")
I would get a String[] array
like this:
{"What time", "What day", "What month", "Asdf"}
But I want this:
{"What time", "\n", "What day", "\n", "What month", "\n", "\n" ....}
Is there any built-in property I need to set or do I have to implement this from scratch.