# Please answer question correctly and show the result of the working code. The actual and demo...

###### Question:

Please answer question correctly and show the result of the working code. The actual and demo code is provided .must take command line arguments of text files for ex : input.txt output.txt from a filetext(any kind of input for the text file should work as it is for testing the question)

This assignment is about using the Java Collections Framework to accomplish some basic text-processing tasks.

These questions involve choosing the right abstraction (Collection, Set, List, Queue, Deque, SortedSet, Map, or SortedMap) to efficiently accomplish the task at hand. The best way to do these is to read the question and then think about what type of Collection is best to use to solve it. There are only a few lines of code you need to write to solve each of them.

Unless specified otherwise, sorted order refers to the natural sorted order on Strings, as defined by String.compareTo(s).

$Part0.java is a sample program that reads data one line at a time from some input source and writes data to an output destination. You should use this as a basis for code.$
$5) [12.5 marks] Read the whole input one line at a time. Then output all lines sorted by length, with the shortest lines first. In the case where two lines have the same length, resolve their order using the usual "sorted order".$
$import java.io.BufferedReader; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashSet; import java.util.Iterator; import java.util.Set; public class Part0 { /** * Read lines one at a time from r. After reading all lines, output * all lines to w, outputting duplicate lines only once. Note: the order * of the output is unspecified and may have nothing to do with the order * that lines appear in r. * @param r the reader to read from * @param w the writer to write to * @throws IOException */ public static void doIt(BufferedReader r, PrintWriter w) throws IOException { Set s = new HashSet<>(); for (String line = r.readLine(); line != null; line = r.readLine()) { s.add(line); } for (String text : s) { w.println(text); } } /** * The driver. Open a BufferedReader and a PrintWriter, either from System.in * and System.out or from filenames specified on the command line, then call doIt. * @param args */ public static void main(String[] args) { try { BufferedReader r; PrintWriter w; if (args.length == 0) { r = new BufferedReader(new InputStreamReader(System.in)); w = new PrintWriter(System.out); } else if (args.length == 1) { r = new BufferedReader(new FileReader(args[0])); w = new PrintWriter(System.out); } else { r = new BufferedReader(new FileReader(args[0])); w = new PrintWriter(new FileWriter(args[1])); } long start = System.nanoTime(); doIt(r, w); w.flush(); long stop = System.nanoTime(); System.out.println("Execution time: " + 10e-9 * (stop-start)); } catch (IOException e) { System.err.println(e); System.exit(-1); } } }$
$import java.io.BufferedReader; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; public class Part5 { /** * Your code goes here - see Part0 for an example * @param r the reader to read from * @param w the writer to write to * @throws IOException */ public static void doIt(BufferedReader r, PrintWriter w) throws IOException { // Your code goes here - see Part0 for an example } /** * The driver. Open a BufferedReader and a PrintWriter, either from System.in * and System.out or from filenames specified on the command line, then call doIt. * @param args */ public static void main(String[] args) { try { BufferedReader r; PrintWriter w; if (args.length == 0) { r = new BufferedReader(new InputStreamReader(System.in)); w = new PrintWriter(System.out); } else if (args.length == 1) { r = new BufferedReader(new FileReader(args[0])); w = new PrintWriter(System.out); } else { r = new BufferedReader(new FileReader(args[0])); w = new PrintWriter(new FileWriter(args[1])); } long start = System.nanoTime(); doIt(r, w); w.flush(); long stop = System.nanoTime(); System.out.println("Execution time: " + 10e-9 * (stop-start)); } catch (IOException e) { System.err.println(e); System.exit(-1); } } }$

#### Similar Solved Questions

##### Assume the following information: Milling Department Materials Conversion Total Cost of beginning work in process inventory...
Assume the following information: Milling Department Materials Conversion Total Cost of beginning work in process inventory $10,000$ 15,000 $25,000 Costs added during the period 291,600 385,000 676,600 Total cost$ 301,600 $400,000$ 701,600 Assume the equivalent units of production for material...
##### A converging lens makes an image of an object located a finite distance away. Which of...
A converging lens makes an image of an object located a finite distance away. Which of the following statements is true? A. The image is virtual B. The image is real C. the object distance is positive D. the object distance is negative E. the image can be either real or virtual...
##### If a 490 mL ordinary glass beaker is filled to the brim with ethyl alcohol at...
If a 490 mL ordinary glass beaker is filled to the brim with ethyl alcohol at a temperature of 6.00°C, how much (in mL) will overflow when their temperature reaches 22.0°C? mL (b) How much less water would overflow under the same conditions? mL...
##### 15) 5. For this molecule: a. How many chemically different hydrogens? b. How many chemically different...
15) 5. For this molecule: a. How many chemically different hydrogens? b. How many chemically different carbons? c. What would be the mass of the molecular ion in El-MS?...
##### Epidemiology: confounding (10) In the early 1940s, epidemiologists and public health officials set out to prove...
Epidemiology: confounding (10) In the early 1940s, epidemiologists and public health officials set out to prove hat smoking causes lung cancer. Epidemiologists designed studies, analyzed data, and constructed logical arguments to demonstrate this relationship. Cigarette companies argued that ass...
##### 8. (a) For what values of a, b, and c can the matrix A below be...
8. (a) For what values of a, b, and c can the matrix A below be diagonalized? 2 marks 0 a 1 0 =10 0 0 c b) Let A be an n xn matrix. In class, we showed that if R" admits a basis of eigenvectors of A, then there is an invertible atrix P such that P- AP is diagonal (i.e., is zero everywhere apart ...
##### Describe the life cycle of Toxoplasma gondii in the nonfeline host and describe its importance to...
Describe the life cycle of Toxoplasma gondii in the nonfeline host and describe its importance to veterinary and human medicine. Also discuss how transmission to humans can be prevented.  ...
##### How do you find the limit of (1+2/x)^x as x approaches oo?
How do you find the limit of (1+2/x)^x as x approaches oo?...
##### Suppose that a particle starts at the origin of the real line and moves along the...
Suppose that a particle starts at the origin of the real line and moves along the line in jumps of one unit. For each jump, the probability is p(0≤p≤1) that the particle will jump one unit to the left and the probability is 1−p that the particle will jump one unit to the right. Find the ...