[solved]-Trouble Writing Correct Code Read Text File Code Public Void Listofitemsavailable Scanner Q39011772
I am having trouble writing the correct code to read from thetext file.
This the code
public void ListOfItemsAvailable(){
Scanner itemList = null;
try {
itemList= new Scanner(new File (“listOfItems.txt”));
while( itemList.hasNext()){
listOfItems.add(itemList.nextLine());
itemCount++;
}
}
catch (Exception ex) {
JOptionPane.showMessageDialog(null, “Error reading availableitems”);
System.exit(1);
}
Expert Answer
Answer to I am having trouble writing the correct code to read from the text file. This the code public void ListOfItemsAvailable(… . . .
OR

