in java' Variables fStream and dataFS are FileInputStream and Scanner, respectively. String fileName is assigned a file's name read from input. Perform the following tasks: Assign fStream with a FileInputStream that opens the file fileName for reading. Assign dataFS with a Scanner created using fStream.   Click here for example Ex: If the input is peach2.txt and:   Data in file peach2.txt 4.3 then the output is: 4.3 GroceryDataProcessor.java peach1.txt peach2.txt peach3.txt         public class GroceryDataProcessor { publicstaticvoidmain(String[] args) throwsIOException { Scannerscnr=newScanner(System.in); StringfileName; doublepeachWeight; FileInputStreamfStream=null; ScannerdataFS=null;   fileName=scnr.next();   /* Your code goes here */   peachWeight=dataFS.nextDouble(); System.out.println(peachWeight);   fStream.close(); } }

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question

in java'

Variables fStream and dataFS are FileInputStream and Scanner, respectively. String fileName is assigned a file's name read from input. Perform the following tasks:

  1. Assign fStream with a FileInputStream that opens the file fileName for reading.
  2. Assign dataFS with a Scanner created using fStream.

 

Click here for example
Ex: If the input is peach2.txt and:

 

Data in file peach2.txt
4.3


then the output is:

4.3
GroceryDataProcessor.java
peach1.txt
peach2.txt
peach3.txt
 
 
 
 
public class GroceryDataProcessor {
publicstaticvoidmain(String[] args) throwsIOException {
Scannerscnr=newScanner(System.in);
StringfileName;
doublepeachWeight;
FileInputStreamfStream=null;
ScannerdataFS=null;
 
fileName=scnr.next();
 
/* Your code goes here */
 
peachWeight=dataFS.nextDouble();
System.out.println(peachWeight);
 
fStream.close();
}
}
 
 
 
AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning