Question: Write a Java program name Extract.java that takes several command line parameters. The first parameter should be interpreted as the name of a source file,

Write a Java program name Extract.java that takes several command line parameters. The first parameter should be interpreted as the name of a source file, the second as the name of a target file, and then any parameters after that should be integers and will be interpreted as a set of indices. The program should create a new target file with the specified name. It should then copy from the source file the line numbers indicated by the indices provided on the command line. For example, suppose the program is run using the command line: java Extract source.txt target.txt 4 1 7 2 8 and suppose the file source.txt contains the following contents ice nice green red today blue computer yell scream shout fight then the program should create a file named target.txt whose contents should be: ice nice red computer yell

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!