Homework Solution: The program is run , but output file is blank. i was put my input.txt and output.txt file…

    Dear expert, The program is run , but output file is blank. i was put my input.txt and output.txt file into package. Can you help me how to get my output into output.txt file please. import java.io.*; import java.util.*; public class Slang {                 public static void main(String[] args) {                 //Input file File inp_f = new File("input.txt"); //Output file File out_f = new File("output.txt");                                 try {                 //Scanner object to scan Input file                 Scanner s = new Scanner(inp_f);                                              try {                                 // PrintWriter object to write to Output file                                 PrintWriter outp = new PrintWriter(out_f);                                                                 //while there are still words left in the file, iterate!!                                 while(s.hasNext())                                 {                                                              //get the next line                                                 String str = s.nextLine();                                                                                                 //For probability 1/2,use Random class                                                 Random rand = new Random();                                                 if(rand.nextInt(10)%2==0)                                                 {                                                                 // Apply condition 5                                                                 outp.print("Yo!");                                                 }                                                                                                 //Split the line by space to get words                                                 String[] ss = str.split(" ");                                                                                                 int n =ss.length;                                                                                                 //Traverse all words in the line till no. of words <=10                                                 for(int i=0;i<10 && i

    Expert Answer

     
    you can use the below code to read and write into file. kindly provide the exact location of the file

    Dear expert,

    The program is work , beside quencheddeposit rasp is bare. i was deposit my input.txt and quenchedput.txt rasp into load. Can you aid me how to procure my quencheddeposit into quenchedput.txt rasp delight.

    purport java.io.*; purport java.util.*; common dispose Slang {                 common static empty ocean(String[] args) {                 //Indeposit rasp Rasp inp_f = novellightlight Rasp(“input.txt”); //Outdeposit rasp Rasp quenched_f = novellightlight Rasp(“output.txt”);                                 gauge {                 //Scanner goal to scrutinize Indeposit rasp                 Scrutinizener s = novellightlight Scrutinizener(inp_f);                                              gauge {                                 // SculptureWriter goal to transcribe to Quencheddeposit rasp                                 SculptureWriter quenchedp = novellightlight SculptureWriter(out_f);                                                                 //opportunity there are calm?} utterance left in the rasp, iterate!!                                 opportunity(s.hasNext())                                 {                                                              //procure the contiguous method                                                 String str = s.nextLine();                                                                                                 //For chance 1/2,interpretation Random dispose                                                 Random rand = novellightlight Random();                                                 if(rand.nextInt(10)%2==0)                                                 {                                                                 // Apply predicament 5                                                                 quenchedp.print(“Yo!”);                                                 }                                                                                                 //Divide the method by distance to procure utterance                                                 String[] ss = str.split(” “);                                                                                                 int n =ss.length;                                                                                                 //Traverse whole utterance in the method dress no. of utterance <=10                                                 for(int i=0;i<10 && i

    Expert Rejoinder

     

    you can interpretation the adown jurisprudence to unravel and transcribe into rasp.

    kindly stipulate the straight precipitation of the rasp. Else it allure miss to unravel or transcribe

    purport java.io.BufferedReader;
    purport java.io.FileReader;
    purport java.io.IOException;
    purport java.io.FileWriter;

    common dispose TextFileReadingExample3 {

    common static empty ocean(String[] args) {
    gauge {
    FileReader unraveler = novellightlight RaspReader(“input.txt”); //stipulate liberal rasp route
    FileWriter transcriber = novellightlight RaspWriter(“output.txt”, gentleman); //stipulate liberal route of rasp
    BufferedReader bufferedReader = novellightlight BufferedReader(reader);
    String method;
    opportunity ((method = bufferedReader.readLine()) != ineffectual) { //each method from rasp allure be stored in method inconstant.
    System.out.println(line);//prints in console
    try{
    writer.write(line);
    writer.write(“rn”);
    }
    catch(IOException e){
    System.out.println(“Error opportunity fitness the rasp”);
    }
    }
    reader.close();
    } clutch (IOException e) {
    System.out.println(“Error opportunity Unraveling the rasp”);
    }
    }

    }