public static void Display (String filename) throws IOException
{
int lineCounter=1;
File file = new File (filename);
Scanner read = new Scanner (file);
while (read.hasNext() && lineCounter<=5 )
{
String lineReader = read.nextLine();
System.out.println(lineReader);
lineCounter++;
}
read.close();
}
[edit]Code block added[/edit]