at the moment I am trying to read in a text file of strings and put them into an array for each line. The text file has 10 lines and each line has a string of words (sentences extracted from a website). My aim is store these strings into arrays (an array for each line).
This is the code I am using at the moment package array;
public class sep_arr
{
public static void main (String[] args) throws FileNotFoundException
{
Scanner DataFile = new Scanner(new File("EntityTagged.txt"));
while(DataFile.hasNextLine()){
String line = DataFile.nextLine();
ArrayList<String> salesData = new ArrayList<String>();
Scanner scanner = new Scanner(line);
scanner.useDelimiter(",");
while(scanner.hasNextDouble()){
salesData.add(scanner.toString());
}
scanner.close();
System.out.println(salesData);
}
DataFile.close();
}
}
The code reads in the 'EntityTagged.txt' file which has the 10 different sentences in and looks to store them in an array. At the moment, when executed, it returns empty arrays
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
My goal is to store the sentences in these arrays to then use the 'endsWith() method' to extract specific words from the text.
Any help will be much appreciated
Thank you