How do I read in a file into a string array using Scanner? The file has a specified number of lines, lets say 100. There are plenty of examples in here using arrayList and BufferedReader but not Scanner or arrays that are already fixed in size.
public String[] array;
Scanner inputStream = null;
public String line;
public practice(String theFile) {
array = new String[100];
try {
inputStream = new Scanner(new FileInputStream(theFile));
while (inputStream.hasNextLine()) {
for (int i = 0; i < array.length; i++){
//dont know what to put here
}
}
} catch(FileNotFoundException e) {
System.out.println(e.getMessage());
}
inputStream.close();
}