import java.io.*;
class ViewFile
{
public static void main(String[] args) throws Exception
{
FileViewer fv = new FileViewer(args[0]);
BufferedReader in =
new BufferedReader(
new InputStreamReader(System.in)
);
boolean stillViewing = true;
while (stillViewing)
{
switch (getCommand(in))
{
case 'n':
case 'd':
fv.next();
break;
case 'p':
case 'u':
fv.previous();
break;
case 'f':
case 't':
fv.first();
break;
case 'l':
case 'b':
fv.last();
break;
case 'q':
case 'e':
case 'c':
case 'x':
stillViewing = false;
break;
default:
System.out.println("=== Try again ===");
}
}
fv.close();
}
static char getCommand(BufferedReader in) throws IOException
{
// Prompt for a user command
// ... implementation omitted
}
}
End of Listing