ReverseFile.java Source code

Java tutorial

Introduction

Here is the source code for ReverseFile.java

Source

import java.io.RandomAccessFile;

class ReverseFile {

    public static void main(String args[]) throws Exception {
        RandomAccessFile raf = new RandomAccessFile(args[0], "r");
        long position = raf.length();
        while (position > 0) {
            position -= 1;
            raf.seek(position);
            byte b = raf.readByte();
            System.out.print((char) b);
        }
    }
}