import java.io.EOFException; import java.io.RandomAccessFile; class Tail { public static void main(String args[]) throws Exception { RandomAccessFile raf = new RandomAccessFile(args[0], "r"); long count = 10; long position = raf.length(); position -= count; if (position < 0) position = 0; raf.seek(position); while (true) { try { byte b = raf.readByte(); System.out.print((char) b); } catch (EOFException eofe) { break; } } } }