ajanuskevicius
2/15/2017 - 1:52 PM

Java - Split Text into Lines and Words

Java - Split Text into Lines and Words

Text = "Some text with line breaks";

//Splits text by lines
String[] lines = Text.split(System.getProperty("line.separator"));

//Splits line in words by spec. character - space "\\s"
String[] line = lines[0].split("\\s");