help me rewrite the code without using bufferReader please

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter14: Files And Streams
Section: Chapter Questions
Problem 2E: Create a program named FileComparison that compares two files. First, use a text editor such as...
icon
Related questions
Question

help me rewrite the code without using bufferReader please 

 

//creating a scanner
Scanner fileName2 = new Scanner (System.in);
System.out.println("fileName");
//reads the users input
String fileName1 = fileName2.nextLine();
String fileName = fileName1;
try (BufferedReader fileReader = new BufferedReader (new FileReader (fileName));) {
int sum = 0;
while (true){
String lineRead = fileReader.readLine(O;
if(lineRead =- null) {
break;
}
int num =
Integer.parseInt(lineRead);
sum += num;
System.out.println("sum of the number in text file :"
+ sum);
tch (IOException ioex) {
System.out.println("Error");
Transcribed Image Text://creating a scanner Scanner fileName2 = new Scanner (System.in); System.out.println("fileName"); //reads the users input String fileName1 = fileName2.nextLine(); String fileName = fileName1; try (BufferedReader fileReader = new BufferedReader (new FileReader (fileName));) { int sum = 0; while (true){ String lineRead = fileReader.readLine(O; if(lineRead =- null) { break; } int num = Integer.parseInt(lineRead); sum += num; System.out.println("sum of the number in text file :" + sum); tch (IOException ioex) { System.out.println("Error");
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Files and Directory
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
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L