Hi,

I'm trying to figure out how can I make split read from the file and recognize how to put the strings into an array from a file, based on a new line break.

Example of my txt file:

This will be my first huge paragraph, it will contain many different characters such as numbers (123...) periods and etc...

My second paragraph, once again pretty big. Each paragraph consisting of about 50 - 150 characters.

Third paragraph, ans so on. Looking for an aim for atleast 50+ paragraphs.

Please suggest what would be the best and simple method to approach this. Thanks!

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
}
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
  }
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

This article has been dead for over six months. Start a new discussion instead.