import java.util.*; import java.io.*; /** * This class was created for Java Network Programming. * It implements a basic version of the unix command's "tail" program. * * @author JJ Johns * @version 1.0 **/ public class tail { /** * This field denotes if the call to tail should block and wait, or not. **/ private static boolean threaded = false; /** * This is the number of lines that tail should print. **/ private static int num_lines = 10; /** * This is the mail function, which parses command line parameters. * * This will set flags for -f, which will wait for more data to appear * at the end of the file, and print it when it comes. * This will also accept -n, which tells the program how many lines from * the end to print out. * * @param argv The command line arguments. **/ public static void main(String argv[]) { String filename = null; // parse the command line try { for( int i=0; inum_lines) lines.remove( lines.getFirst()); } else break; } } catch (FileNotFoundException fnfe) { System.err.println("The file " + filename + " was not found."); System.exit(0); try { br.close(); } catch (IOException ioe) { } } catch(IOException ioe) { System.out.println("Error reading from file " + filename ); System.exit(0); try { br.close(); } catch (IOException ioe2) { } } // print out the specified number of lines. for (int i=0; i