Question: String fileName is assigned a file's name read from input. Perform the following tasks: Assign groceryStream with a FileInputStream that opens the file fileName for

String fileName is assigned a file's name read from input. Perform the following tasks:
Assign groceryStream with a FileInputStream that opens the file fileName for reading.
Assign dataFS with a Scanner created using groceryStream.
Click here for example
GroceryDataProcessor.java
pearData1.txt
pearData2.txt
pearData3.txt
import java.util.Scanner;
import java.io.FileInputStream;
import java.io.IOException;
public class GroceryDataProcessor {
public static void main(String[] args) throws IOException {
Scanner scnr = new Scanner(System.in);
String fileName;
double pearWeight;
FileInputStream groceryStream = null;
Scanner dataFS = null;
fileName = scnr.next();
/* Your code goes here */
pearWeight = dataFS.nextDouble();
System.out.println(pearWeight);
groceryStream.close();
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!