Java String lines() method
Java String lines() method
String lines() method added jdk 11.
Returns a stream of lines extracted from this string, separated by line terminators.
A line terminator is one of the following: a line feed character "\n" (U+000A), a carriage return character "\r" (U+000D), or a carriage return followed immediately by a line feed "\r\n" (U+000D U+000A).
A line is either a sequence of zero or more characters followed by a line terminator, or it is a sequence of one or more characters followed by the end of the string. A line does not include the line terminator.
The stream returned by this method contains the lines from this string in the order in which they occur.
Java Program Example:
class StringLines{public static void main(String args[]){
String str = "this is a test example."
str.lines().stream()......// process with stream api
}
}
Comments
Post a Comment