Very noobish questions but I want to read a file and have an array of paragraphs from that file. The paragraphs are separated by empty lines.
Example: String str = "Johnny likes to go outside but the weather has been so hot lately I don't think he'll be able to go unless his mother is cool with sunburns all over his body. Someone needs to help him understand that money doesn't grow on trees and unless you have sunscreen money then don't ask to go outside.
Melissa likes to go outside too but she wouldn't have anybody to play with because johnny's mom turned psycho. Kids get sunburned...that's just some kid stuff to do... why are you upset at that?";
Would be one string, if I used split() to make a String array I'd have 2 items in there because they are separated by an empty line...
class Main {
public static String[] fileSearch(String fileName) throws IOException, NullPointerException {
BufferedReader items = new BufferedReader(new FileReader(fileName));
String line = items.readLine();
while(line != null)
{
//Where I want my file to be split by paragraph, I used "/n" but that's not what I really want.
String[] data = line.split("\n");
line = items.readLine();
}
return data;
}
public static void main(String[] args) {
fileSearch(info.txt);
}
}