Write a class called fileoperations that accepts a string


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.

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.

f) The declaration of appropriate variables and use of Exception where necessary.

Note :- a test class is NOT required

Exceptions identify errors that arise in your program. Name the two categories of exceptions that are derived directly from Throwable and differentiate between them.

Solution Preview :

Prepared by a verified Expert
Macroeconomics: Write a class called fileoperations that accepts a string
Reference No:- TGS01687345

Now Priced at $20 (50% Discount)

Recommended (93%)

Rated (4.5/5)