Question: In Java FileDisplay class Write a class named FileDisplay with the following methods: -Constructor. The class's constructor should take the name of the file as

In Java
FileDisplay class
Write a class named FileDisplay with the following methods:
-Constructor. The class's constructor should take the name of the file as an argument.
-displayHead. This method should only the first five lines of the file's contents. If the file contains less than five lines, it should display the file's entire content.
-displayContents. This method should display the entire contents of the file, the name of which was passed to the constructor.
-displayWithLineNumbers. This method should display the contents of the file, the name of which was passed to the constructor. Each line should be preceded with a line number followed by a colon. The line numbering should start at 1.

Step by Step Solution

3.46 Rating (162 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Sure Lets create the FileDisplay class in Java and implement the methods as described Heres how you can write this program java import javaioBufferedR... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!