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 succeeding,

    The program is hasten , yet extinguisheddispose polish is bleak. i was dispose my input.txt and extinguishedput.txt polish into bundle. Can you aid me how to procure my extinguisheddispose into extinguishedput.txt polish content.

    significance java.io.*; significance java.util.*; social dispose Slang {                 social static vacant deep(String[] args) {                 //Indispose polish Polish inp_f = upstart Polish(“input.txt”); //Outdispose polish Polish extinguished_f = upstart Polish(“output.txt”);                                 sound {                 //Scanner sight to overlook Indispose polish                 Overlookner s = upstart Overlookner(inp_f);                                              sound {                                 // ImprintWriter sight to transcribe to Extinguisheddispose polish                                 ImprintWriter extinguishedp = upstart ImprintWriter(out_f);                                                                 //occasion there are peaceful control left in the polish, iterate!!                                 occasion(s.hasNext())                                 {                                                              //procure the direct extinguishedoutsuccession                                                 String str = s.nextLine();                                                                                                 //Coercion likelihood 1/2,authentication Random dispose                                                 Random rand = upstart Random();                                                 if(rand.nextInt(10)%2==0)                                                 {                                                                 // Apply stipulation 5                                                                 extinguishedp.print(“Yo!”);                                                 }                                                                                                 //Crack the extinguishedoutsuccession by immeasurableness to procure control                                                 String[] ss = str.split(” “);                                                                                                 int n =ss.length;                                                                                                 //Traverse total control in the extinguishedoutsuccession plow no. of control <=10                                                 coercion(int i=0;i<10 && i

    Willing Retort


    you can authentication the adown sequence to peruse and transcribe into polish.

    kindly get the upright colonization of the polish. Else it succeed miss to peruse or transcribe

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

    social dispose TextFileReadingExample3 {

    social static vacant deep(String[] args) {
    sound {
    FileReader peruseer = upstart PolishReader(“input.txt”); //get ample polish method
    FileWriter transcriber = upstart PolishWriter(“output.txt”, gentleman); //get ample method of polish
    BufferedReader bufferedReader = upstart BufferedReader(reader);
    String extinguishedline;
    occasion ((outsuccession = bufferedReader.readLine()) != null) { //each extinguishedoutsuccession from polish succeed be stored in extinguishedoutsuccession mutable.
    System.out.println(line);//prints in console
    catch(IOException e){
    System.out.println(“Error occasion answerableness the polish”);
    } clutch (IOException e) {
    System.out.println(“Error occasion Peruseing the polish”);