import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; /** * Uses a Scanner to read from a specified file into the given LineStorage. * * @author Alexander Schaap * * @param * - type of word */ public class Input> extends InputAbstract { /** * Parses an input file into the given storage using the given WordCommand. * Passing an instance of an implementation of a helper interface to define * the type of Word using generics. Uses a Scanner. * */ @Override public void parse(String filename) { Scanner s; try { s = new Scanner(new File(filename)); while (s.hasNextLine()) { String[] line = s.nextLine().split(" "); StorageInterface> words = new StorageObservableArrayList>(); for (int i = 0; i < line.length; i++) { words.add(wc.convert(line[i])); } ls.add(words); } s.close(); } catch (FileNotFoundException e) { System.out.println("File not found, try again."); } } }