Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

Write a Java program. The program should ask the user for the name of an input file and the name of
an output file. It should then open the input file as a text file (if the input file
does not exist it should throw an exception) and read the contents line by line.
It should also open the output file as a text file and write to it the lines in the
input file, prefixed by line numbers starting at 1.
So if an input file named “fred.txt” contains:

Hello,
I am Fred.
I enrolled in JT179.
Bye

 

and the user enters “fred.txt” and “fredNum.txt”, then after running the
program “fredNum.txt” will contain something like:

 

1 Hello,
2
3 I am Fred.
4 I enrolled in JT179.
5
6 Bye

 

Finally, the program should display on the screen your name, the name of the
output file, followed by a count of the total number of lines, the total number
of words, and the total number of characters in the input file.
For the above input file, the following will be displayed to the screen:
My name = Joe Bloggs
Name of Output file = fredNum.txt
Total number of lines in fred.txt = 6
Total number of words in fred.txt = 10
Total number of characters in fred.txt = 43

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
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
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education