Do you want to use String.split(String regex):
Returns: an array of strings calculated by breaking this string around matches of a given regular expression
So maybe something like this:
String[] newStringArray = textAreaContent.split("\n");
This splits the string textAreaContentaround matches "\n", which is the normalized line break for Swing text editors (as specified in the javax.swing.text.DefaultEditorKitAPI ):
[...], , "\n" , , , . "\n".
(, ?), , .
String[] parts = "xx;yyy;z".split(";");
for (String part : parts) {
System.out.println("<" + part + ">");
}
:
<xx>
<yyy>
<z>
:
String[] lines = "\n\nLine1\n\n\nLine2\nLine3".trim().split("\n+");
for (String line : lines) {
System.out.println("<" + line + ">");
}
:
<Line1>
<Line2>
<Line3>