Question: Write a one-class program called Lines that takes a single file name as a command line argument and creates a new file, output.txt that
Write a one-class program called Lines that takes a single file name as a command line argument and creates a new file, output.txt that is a copy of the specified file except that each line is preceded by line numbers. For example if the input file is called happy.txt and contains: Happy happy! Joy joy! It's the happy happy joy joy song! Then output.txt should contain: /*1*/ Happy happy! /* 2*/ Joy joy! /*3*/ It's the happy happy /* 4 */ joy joy /* 5 */ song! Make sure your program does not print anything. It must take one and only one command line argument. That argument should be the name of the input file. It should then create a new file called (output. txt that should be a line-numbered version of the original. In the above example, running the file should look like this: java Lines happy.txt This should write a new file called output.txt with the added line numbers as described above. Please use the template for Lines.java provided on Codio.
Step by Step Solution
3.37 Rating (156 Votes )
There are 3 Steps involved in it
import javaio Buffered Reader import javaioBuffered Writer import javaioFi... View full answer
Get step-by-step solutions from verified subject matter experts
