Create a java file named linesorter - you will write a


Sorting Lines in a File
Create a java file named LineSorter
You will write a program that will take the names of two text files as command line arguments. (Only the first file needs to exist. You'll be writing the second one.)
It will read all the lines from the first file, sort them by length, and write them to the second file.
The lines should be sorted so that the shortest line is first. (Note: comparing length is not the default ordering for Strings.)
If two lines are the same length, compare them lexicographically to break the tie. (That is, use the natural ordering of the String type.)

Test input file
This is a test.
Only a test.
A test of your code.
Some lines have white space
some are lowercase
1234 some have numbers

some even were blank

some lines are the same length A
some lines are the same length C
some lines are the same length B

It doesn't matter what characters are on the line or how long it is.
I'm sure your code can sort them all.
!@#$%^&* (even if there are special characters)
really, don't go overthinking this one.

Test output file

Only a test.
This is a test.
some are lowercase
A test of your code.
some even were blank
1234 some have numbers
Some lines have white space
some lines are the same length A
some lines are the same length B
some lines are the same length C
I'm sure your code can sort them all.
really, don't go overthinking this one.
!@#$%^&* (even if there are special characters)
It doesn't matter what characters are on the line or how long it is.

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Create a java file named linesorter - you will write a
Reference No:- TGS02383507

Now Priced at $15 (50% Discount)

Recommended (95%)

Rated (4.7/5)