Ok, I figured it out with some of your comments. Thanks to all for your input.
Here is my final version. I am posting just for FYI. You can comment more if you feel like. Any help on improving my techniques is always welcome. Thanks again.
import java.util.Scanner;
import java.io.*;
public class FileDisplay
{
String fileName, //stores file name
head; //reads file for displayHead
int count,
diffCount=0; //counter
//constructor to accept name of file
public FileDisplay (String nameOfFile)
{
fileName = nameOfFile;
}
//method to display first 5 names in list from file
public String displayHead() throws IOException
{
//open file
File file = new File (fileName);
Scanner inputHead = new Scanner(file);
//loop to count and print first 5 lines from file
for (count =1; count <=5; count++)
{
//reads each line from file
head =inputHead.nextLine();
//prints each line from file
System.out.println(head);
}
inputHead.close();
//returns output to main program
return " ";
}
//method to display file name and all names from the file
public String displayContents() throws IOException
{
//open file
File contentFile = new File(fileName);
Scanner inputContents = new Scanner(contentFile);
//loop to count and print lines from file
while (inputContents.hasNextLine())
{
//reads each line from file
String contents = inputContents.nextLine();
//prints each line from file
System.out.println(contents);
}
inputContents.close();
//returns output to main program
return "";
}
//method to display lines from file numbered
public String displayNumberedContents() throws IOException
{
//open file
File numberedContents = new File (fileName);
Scanner inputNumContents = new Scanner(numberedContents);
//loop to count and print lines from file and accumulate to number lines
while (inputNumContents.hasNextLine())
{
//read lines from file
String numContents = inputNumContents.nextLine();
//accumulator for numbering lines
diffCount++;
//print numbering plus lines from file
System.out.println(diffCount + " " + numContents);
}
inputNumContents.close();
//returns output to main file
return"";
}
}