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

Write a complete implementation of a method aggressivelyCensor. It takes an inpu

ID: 3583066 • Letter: W

Question

Write a complete implementation of a method aggressivelyCensor.

It takes an input filename and an output filename as parameters and does not return a value. Your implementation should read each line of the input file, and write the line if and only if it dost not contain ‘@’ character. If there are any errors opening, reading, or writing the files, print an appropriate error message and return. (Hint: You will need to use Scanner to read, PrintWriter to write, and must handle the exception FileNotFoundException).

Explanation / Answer

import java.io.BufferedReader;
import java.io.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;


public class KETTask2Overview
{

    public static void main(String[] args)
    {
        Scanner input = new Scanner(System.in);
        String strInput = "foo.bar";
        System.out.print("Please enter the listings file (the full path to the file): ");
        strInput = input.next();

      
        while (strInput.contains("listings.txt") == false)
        {
            System.out.print("Incorrect file. Please enter listings file(the full path to the file): ");
            strInput = input.next();
        }

        infos(strInput);
        input.close();
    }

    public static void infos(String strInput)
    {
        Scanner input2 = new Scanner(System.in);
        System.out.print("Please enter the overview.txt file (the full path to the file): ");
        String strInput2 = "foo.bar";
        strInput2 = input2.next();

       
        while (strInput2.contains("overview.txt") == false)
        {
            System.out.print("Incorrect file. Please enter overview file(the full path to the file): ");
            strInput2 = input2.next();
        }

     
        File f = new File(strInput2);

        try
        {
         
            PrintWriter out = new PrintWriter(strInput2);
        }  
        catch (FileNotFoundException ex)
        {
            Logger.getLogger(KETTask2Overview.class.getName()).log(Level.SEVERE, null, ex);
        }

      
        String inputLine = "";

      
        try
        {
            BufferedReader in = new BufferedReader(new FileReader(strInput));
            FileWriter fstream = new FileWriter(strInput2);
            BufferedWriter out = new BufferedWriter(fstream);
            while (in.readLine() != null) {
                out.write(in.read());
            }
            in.close();
        }
        catch (IOException e)
        {
            System.err.println("Error: " + e.getMessage());
        }

    }
}

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