SlideShare a Scribd company logo
You will make changes to the class called ReadFile .
Complete the progam so that it prints the contents of the file specified by the user (code is
provided for user input) to System.out .
There are several important requirements:
The main method must not be declared to throw any kind of exception.
The program must not test whether or not the requested file exists before attempting to open it.
The program must use a try/finally block to make sure that the reader or input stream reading
the file is closed before the program exits.
There is a file myFile.txt provided that contains the following contents:
Here is an example session showing a file being printed successfully (user input in bold ):
Here is another example session showing what happens when the user enters the name of a
nonexistent file:
Hints
Use a try/catch block to handle an IOException or FileNotFoundException that might occur.
Print the error message from the catch block. You can call the getMessage method on the caught
exception object to get a string containing a textual description of the error that caused the
exception.

More Related Content

Similar to You will make changes to the class called ReadFile- Complete the proga.pdf

errno is an integer variable, defined in errno.h, that is set by sys.pdf
errno is an integer variable, defined in errno.h, that is set by sys.pdferrno is an integer variable, defined in errno.h, that is set by sys.pdf
errno is an integer variable, defined in errno.h, that is set by sys.pdf
arjuntiwari586
 
File Management and manipulation in C++ Programming
File Management and manipulation in C++ ProgrammingFile Management and manipulation in C++ Programming
File Management and manipulation in C++ Programming
ChereLemma2
 
Perfomatix - Java Coding Standards
Perfomatix - Java Coding StandardsPerfomatix - Java Coding Standards
Perfomatix - Java Coding Standards
Perfomatix Solutions
 
asdabuydvduyawdyuadauysdasuydyudayudayudaw
asdabuydvduyawdyuadauysdasuydyudayudayudawasdabuydvduyawdyuadauysdasuydyudayudayudaw
asdabuydvduyawdyuadauysdasuydyudayudayudaw
WrushabhShirsat3
 
Introduction To Programming with Python-5
Introduction To Programming with Python-5Introduction To Programming with Python-5
Introduction To Programming with Python-5
Syed Farjad Zia Zaidi
 
Savitch ch 06
Savitch ch 06Savitch ch 06
Savitch ch 06
Terry Yoast
 
Savitch Ch 06
Savitch Ch 06Savitch Ch 06
Savitch Ch 06
Terry Yoast
 
Savitch Ch 06
Savitch Ch 06Savitch Ch 06
Savitch Ch 06
Terry Yoast
 
Use Java to program the following.1. Create public java class name.pdf
Use Java to program the following.1. Create public java class name.pdfUse Java to program the following.1. Create public java class name.pdf
Use Java to program the following.1. Create public java class name.pdf
f3apparelsonline
 
Presentation on-exception-handling
Presentation on-exception-handlingPresentation on-exception-handling
Presentation on-exception-handling
Nahian Ahmed
 
Exception Handling.ppt
 Exception Handling.ppt Exception Handling.ppt
Exception Handling.ppt
Faisaliqbal203156
 
Basic input-output-v.1.1
Basic input-output-v.1.1Basic input-output-v.1.1
Basic input-output-v.1.1
BG Java EE Course
 
I need help with this Java assignment. Please include comments throu.pdf
I need help with this Java assignment. Please include comments throu.pdfI need help with this Java assignment. Please include comments throu.pdf
I need help with this Java assignment. Please include comments throu.pdf
sales98
 
Write a program that asks the user for the name of a file. The progr.pdf
Write a program that asks the user for the name of a file. The progr.pdfWrite a program that asks the user for the name of a file. The progr.pdf
Write a program that asks the user for the name of a file. The progr.pdf
arri2009av
 
Os lecture 6
Os lecture 6Os lecture 6
Os lecture 6
Dr. Ahmed J. Obaid
 
Basic i/o & file handling in java
Basic i/o & file handling in javaBasic i/o & file handling in java
Basic i/o & file handling in java
JayasankarPR2
 
Copyright © 2018 Pearson Education, Inc. C H A P T E R 6.docx
Copyright © 2018 Pearson Education, Inc. C H A P T E R  6.docxCopyright © 2018 Pearson Education, Inc. C H A P T E R  6.docx
Copyright © 2018 Pearson Education, Inc. C H A P T E R 6.docx
dickonsondorris
 
Exception Handling In Python | Exceptions In Python | Python Programming Tuto...
Exception Handling In Python | Exceptions In Python | Python Programming Tuto...Exception Handling In Python | Exceptions In Python | Python Programming Tuto...
Exception Handling In Python | Exceptions In Python | Python Programming Tuto...
Edureka!
 
File Handling
File HandlingFile Handling
File Handling
AlgeronTongdoTopi
 
File Handling
File HandlingFile Handling
File Handling
AlgeronTongdoTopi
 

Similar to You will make changes to the class called ReadFile- Complete the proga.pdf (20)

errno is an integer variable, defined in errno.h, that is set by sys.pdf
errno is an integer variable, defined in errno.h, that is set by sys.pdferrno is an integer variable, defined in errno.h, that is set by sys.pdf
errno is an integer variable, defined in errno.h, that is set by sys.pdf
 
File Management and manipulation in C++ Programming
File Management and manipulation in C++ ProgrammingFile Management and manipulation in C++ Programming
File Management and manipulation in C++ Programming
 
Perfomatix - Java Coding Standards
Perfomatix - Java Coding StandardsPerfomatix - Java Coding Standards
Perfomatix - Java Coding Standards
 
asdabuydvduyawdyuadauysdasuydyudayudayudaw
asdabuydvduyawdyuadauysdasuydyudayudayudawasdabuydvduyawdyuadauysdasuydyudayudayudaw
asdabuydvduyawdyuadauysdasuydyudayudayudaw
 
Introduction To Programming with Python-5
Introduction To Programming with Python-5Introduction To Programming with Python-5
Introduction To Programming with Python-5
 
Savitch ch 06
Savitch ch 06Savitch ch 06
Savitch ch 06
 
Savitch Ch 06
Savitch Ch 06Savitch Ch 06
Savitch Ch 06
 
Savitch Ch 06
Savitch Ch 06Savitch Ch 06
Savitch Ch 06
 
Use Java to program the following.1. Create public java class name.pdf
Use Java to program the following.1. Create public java class name.pdfUse Java to program the following.1. Create public java class name.pdf
Use Java to program the following.1. Create public java class name.pdf
 
Presentation on-exception-handling
Presentation on-exception-handlingPresentation on-exception-handling
Presentation on-exception-handling
 
Exception Handling.ppt
 Exception Handling.ppt Exception Handling.ppt
Exception Handling.ppt
 
Basic input-output-v.1.1
Basic input-output-v.1.1Basic input-output-v.1.1
Basic input-output-v.1.1
 
I need help with this Java assignment. Please include comments throu.pdf
I need help with this Java assignment. Please include comments throu.pdfI need help with this Java assignment. Please include comments throu.pdf
I need help with this Java assignment. Please include comments throu.pdf
 
Write a program that asks the user for the name of a file. The progr.pdf
Write a program that asks the user for the name of a file. The progr.pdfWrite a program that asks the user for the name of a file. The progr.pdf
Write a program that asks the user for the name of a file. The progr.pdf
 
Os lecture 6
Os lecture 6Os lecture 6
Os lecture 6
 
Basic i/o & file handling in java
Basic i/o & file handling in javaBasic i/o & file handling in java
Basic i/o & file handling in java
 
Copyright © 2018 Pearson Education, Inc. C H A P T E R 6.docx
Copyright © 2018 Pearson Education, Inc. C H A P T E R  6.docxCopyright © 2018 Pearson Education, Inc. C H A P T E R  6.docx
Copyright © 2018 Pearson Education, Inc. C H A P T E R 6.docx
 
Exception Handling In Python | Exceptions In Python | Python Programming Tuto...
Exception Handling In Python | Exceptions In Python | Python Programming Tuto...Exception Handling In Python | Exceptions In Python | Python Programming Tuto...
Exception Handling In Python | Exceptions In Python | Python Programming Tuto...
 
File Handling
File HandlingFile Handling
File Handling
 
File Handling
File HandlingFile Handling
File Handling
 

More from solankeanna9

You have to find a way to tie in ALL of the following topics in your m.pdf
You have to find a way to tie in ALL of the following topics in your m.pdfYou have to find a way to tie in ALL of the following topics in your m.pdf
You have to find a way to tie in ALL of the following topics in your m.pdf
solankeanna9
 
You hold a cup of soup when your hand is supinates retracted protracte.pdf
You hold a cup of soup when your hand is supinates retracted protracte.pdfYou hold a cup of soup when your hand is supinates retracted protracte.pdf
You hold a cup of soup when your hand is supinates retracted protracte.pdf
solankeanna9
 
You interrupt DNA replication in E- coli in order to isolate Okazaki f.pdf
You interrupt DNA replication in E- coli in order to isolate Okazaki f.pdfYou interrupt DNA replication in E- coli in order to isolate Okazaki f.pdf
You interrupt DNA replication in E- coli in order to isolate Okazaki f.pdf
solankeanna9
 
you inoculate an EMB agar plate with an unknown organism-After inocula.pdf
you inoculate an EMB agar plate with an unknown organism-After inocula.pdfyou inoculate an EMB agar plate with an unknown organism-After inocula.pdf
you inoculate an EMB agar plate with an unknown organism-After inocula.pdf
solankeanna9
 
You will use the ICP echo client and server code (for IPv4 version) tr.pdf
You will use the ICP echo client and server code (for IPv4 version) tr.pdfYou will use the ICP echo client and server code (for IPv4 version) tr.pdf
You will use the ICP echo client and server code (for IPv4 version) tr.pdf
solankeanna9
 
You were given a sputum sample from a patient- Design an experiment on.pdf
You were given a sputum sample from a patient- Design an experiment on.pdfYou were given a sputum sample from a patient- Design an experiment on.pdf
You were given a sputum sample from a patient- Design an experiment on.pdf
solankeanna9
 
You treat Arabidopsis seed with ethyl methanesulphonate (EMS)- In a pa.pdf
You treat Arabidopsis seed with ethyl methanesulphonate (EMS)- In a pa.pdfYou treat Arabidopsis seed with ethyl methanesulphonate (EMS)- In a pa.pdf
You treat Arabidopsis seed with ethyl methanesulphonate (EMS)- In a pa.pdf
solankeanna9
 
You roll a standard die until you get the number 4 - Round probabiliti.pdf
You roll a standard die until you get the number 4 - Round probabiliti.pdfYou roll a standard die until you get the number 4 - Round probabiliti.pdf
You roll a standard die until you get the number 4 - Round probabiliti.pdf
solankeanna9
 
You oversee the Surgical Center for the only hospital in your communit (1).pdf
You oversee the Surgical Center for the only hospital in your communit (1).pdfYou oversee the Surgical Center for the only hospital in your communit (1).pdf
You oversee the Surgical Center for the only hospital in your communit (1).pdf
solankeanna9
 
You notice that Coca-Cola has a stock price of $41-25 and EPS of $1-71.pdf
You notice that Coca-Cola has a stock price of $41-25 and EPS of $1-71.pdfYou notice that Coca-Cola has a stock price of $41-25 and EPS of $1-71.pdf
You notice that Coca-Cola has a stock price of $41-25 and EPS of $1-71.pdf
solankeanna9
 
You must analyze the entities identified including the bridges- - Enti.pdf
You must analyze the entities identified including the bridges- - Enti.pdfYou must analyze the entities identified including the bridges- - Enti.pdf
You must analyze the entities identified including the bridges- - Enti.pdf
solankeanna9
 

More from solankeanna9 (11)

You have to find a way to tie in ALL of the following topics in your m.pdf
You have to find a way to tie in ALL of the following topics in your m.pdfYou have to find a way to tie in ALL of the following topics in your m.pdf
You have to find a way to tie in ALL of the following topics in your m.pdf
 
You hold a cup of soup when your hand is supinates retracted protracte.pdf
You hold a cup of soup when your hand is supinates retracted protracte.pdfYou hold a cup of soup when your hand is supinates retracted protracte.pdf
You hold a cup of soup when your hand is supinates retracted protracte.pdf
 
You interrupt DNA replication in E- coli in order to isolate Okazaki f.pdf
You interrupt DNA replication in E- coli in order to isolate Okazaki f.pdfYou interrupt DNA replication in E- coli in order to isolate Okazaki f.pdf
You interrupt DNA replication in E- coli in order to isolate Okazaki f.pdf
 
you inoculate an EMB agar plate with an unknown organism-After inocula.pdf
you inoculate an EMB agar plate with an unknown organism-After inocula.pdfyou inoculate an EMB agar plate with an unknown organism-After inocula.pdf
you inoculate an EMB agar plate with an unknown organism-After inocula.pdf
 
You will use the ICP echo client and server code (for IPv4 version) tr.pdf
You will use the ICP echo client and server code (for IPv4 version) tr.pdfYou will use the ICP echo client and server code (for IPv4 version) tr.pdf
You will use the ICP echo client and server code (for IPv4 version) tr.pdf
 
You were given a sputum sample from a patient- Design an experiment on.pdf
You were given a sputum sample from a patient- Design an experiment on.pdfYou were given a sputum sample from a patient- Design an experiment on.pdf
You were given a sputum sample from a patient- Design an experiment on.pdf
 
You treat Arabidopsis seed with ethyl methanesulphonate (EMS)- In a pa.pdf
You treat Arabidopsis seed with ethyl methanesulphonate (EMS)- In a pa.pdfYou treat Arabidopsis seed with ethyl methanesulphonate (EMS)- In a pa.pdf
You treat Arabidopsis seed with ethyl methanesulphonate (EMS)- In a pa.pdf
 
You roll a standard die until you get the number 4 - Round probabiliti.pdf
You roll a standard die until you get the number 4 - Round probabiliti.pdfYou roll a standard die until you get the number 4 - Round probabiliti.pdf
You roll a standard die until you get the number 4 - Round probabiliti.pdf
 
You oversee the Surgical Center for the only hospital in your communit (1).pdf
You oversee the Surgical Center for the only hospital in your communit (1).pdfYou oversee the Surgical Center for the only hospital in your communit (1).pdf
You oversee the Surgical Center for the only hospital in your communit (1).pdf
 
You notice that Coca-Cola has a stock price of $41-25 and EPS of $1-71.pdf
You notice that Coca-Cola has a stock price of $41-25 and EPS of $1-71.pdfYou notice that Coca-Cola has a stock price of $41-25 and EPS of $1-71.pdf
You notice that Coca-Cola has a stock price of $41-25 and EPS of $1-71.pdf
 
You must analyze the entities identified including the bridges- - Enti.pdf
You must analyze the entities identified including the bridges- - Enti.pdfYou must analyze the entities identified including the bridges- - Enti.pdf
You must analyze the entities identified including the bridges- - Enti.pdf
 

Recently uploaded

Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Henry Hollis
 
How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17
Celine George
 
Contiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptxContiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptx
Kalna College
 
MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025
khuleseema60
 
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
RidwanHassanYusuf
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
سمير بسيوني
 
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGHKHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
shreyassri1208
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
blueshagoo1
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
giancarloi8888
 
How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17
Celine George
 
Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)
nitinpv4ai
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
deepaannamalai16
 
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
ImMuslim
 
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxxSimple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
RandolphRadicy
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
Steve Thomason
 
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
220711130083 SUBHASHREE RAKSHIT  Internet resources for social science220711130083 SUBHASHREE RAKSHIT  Internet resources for social science
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
Kalna College
 
Juneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School DistrictJuneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School District
David Douglas School District
 
BPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end examBPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end exam
sonukumargpnirsadhan
 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
EduSkills OECD
 

Recently uploaded (20)

Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
 
How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17
 
Contiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptxContiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptx
 
MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025
 
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
 
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGHKHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
 
How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17
 
Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
 
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
 
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxxSimple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
 
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
220711130083 SUBHASHREE RAKSHIT  Internet resources for social science220711130083 SUBHASHREE RAKSHIT  Internet resources for social science
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
 
Juneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School DistrictJuneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School District
 
BPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end examBPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end exam
 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
 

You will make changes to the class called ReadFile- Complete the proga.pdf

  • 1. You will make changes to the class called ReadFile . Complete the progam so that it prints the contents of the file specified by the user (code is provided for user input) to System.out . There are several important requirements: The main method must not be declared to throw any kind of exception. The program must not test whether or not the requested file exists before attempting to open it. The program must use a try/finally block to make sure that the reader or input stream reading the file is closed before the program exits. There is a file myFile.txt provided that contains the following contents: Here is an example session showing a file being printed successfully (user input in bold ): Here is another example session showing what happens when the user enters the name of a nonexistent file: Hints Use a try/catch block to handle an IOException or FileNotFoundException that might occur. Print the error message from the catch block. You can call the getMessage method on the caught exception object to get a string containing a textual description of the error that caused the exception.