![]() |
VOOZH | about |
In Java, String Plays an important role. As String stores or we can say it is a collection of characters. We want to get a specific line from a multi-line String in Java. This can also be done in Java.
In this article, we will be learning how to extract a specific line from a multi-line String in Java using extractLine() method.
extractLine(): This method extracts the specific line from the multiline string and stores the result in another string.
Below is the implementation of extracting a specific line from a multiline string by using extractLine() and split() methods.
Original String is : She is a very good girl Also, she is very intelligent. She got the first prize. She will definitely make her parents proud. The Specific line is : She got the first prize.
split() method to separate the multi-line string into individual lines based on the newline character (\n).