There are many examples on how to read files in this forum. After you read each line, check if it has value an empty String:
if (line.trim().equals("")) {
// this is an empty line
// the new line would be the start of a new paragraph
}
javaAddict
Nearly a Senior Poster
3,329 posts since Dec 2007
Reputation Points: 1,014
Solved Threads: 448
public void split() {
String s3 = "what ever the text you wish to have with new lines";
String [] temp_store= null; // array to store the separated string
temp_store = s3.split("/n"); // /n is the new line and it will get divide from there and get saved in the array
// have a FOR or a WHILE loop and print it
}
It will not work because the 's3' variable doesn't have the the '\n' character.
And it depends on the way you read the file. The most common way is to read it line by line so you will never have the '\n' in the String read. With every loop you will have the next. What is required (if i understood correctly) is to find a way to separate the paragraphs.
So like I said whenever you read an empty line you have a new paragraph. It depends on how you want to save the lines read
javaAddict
Nearly a Senior Poster
3,329 posts since Dec 2007
Reputation Points: 1,014
Solved Threads: 448