So I am splitting a string by line separators, but I also want to save what line separator was used to use later when putting the string back together. How can I do that?
String data = "Multi\n Line\r Text\n";
List<String> separators = new ArrayList<>();
String lines[] = data.split("\\r?\\n|\\r");
separators.add(???);
I honestly don't know how to capture that. Is it possible with String.Split? Or is there another way that I can go about doing this?
I'm initially getting the string from a File. Is there a way to get and save the line separators that way before converting it into a string?