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

Write a class called FileOperations that accepts a string value in a variable ca

ID: 3741033 • Letter: W

Question

Write a class called FileOperations that accepts a string value in a variable called str which represents the name of a text file residing on an external storage device. Provide the following: (a) A constructor that accepts the string str, representing the file name, and creates a LineNumberReader object. [1 mark] (b) A mutator method that reads the file line by line until the file is empty. (c) An accessor method that determines if the actual file exists. (d) An accessor method that returns the number of bytes in the file. (e) An accessor method that returns the name of the file. (1) The declaration of appropriate variables and use of Exception where necessary. [2 marks] 2 marks] 1 mark] [ 1mark] 1 mark] Note -a test class is NOT required

Explanation / Answer

Below is the java code for above where all the methods are implemented and comments are provided within code itself. The test method is not written as it is not required. The exceptions for file input is declared wherever necessory.

Java Code:

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