Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Now implement a method reverseSequences that takes two Strings as parameters. Th

ID: 3533449 • Letter: N

Question

  1. Now implement a method reverseSequences that takes two Strings as parameters. The first String is the name of an input file containing String values and the second is the name of an output file to write the reverse sequences to. The method should read sequences from the input file one sequence at a time using getSequence and then write them out to the output file. Do not forget to close the output file when the method is finished. Make sure you catch and handle the possible IOException exceptions.
     public static void reverseSequences(String inputFile, String outputFile)


Explanation / Answer

//in command line give sorce.txt and destination.txtimport java.io.File; import java.io.IOException; import java.io.PrintWriter; import java. util.Scanner; public class Reverse { public static void main(String[] args) throws IOException { try{ String source = args[0]; String target = args[1]; File sourceFile=new File(source); Scanner content=new Scanner(sourceFile); PrintWriter pwriter =new PrintWriter(target); while(content.hasNextLine()) { String s=content.nextLine(); StringBuffer buffer = new StringBuffer(s); buffer=buffer.reverse(); String rs=buffer.toString(); pwriter.println(rs); } content.close(); pwriter.close(); } catch(Exception e){ System.out.println("Something went wrong"); } } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote