import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
public class RandomAccessFileDemo {
public static void main(String ... args) throws FileNotFoundException, IOException
{
File file = new File(<FILE_PATH>);
System.err.println("MSR:: RandomAccessFileDemo :: the target length is"+file.length());
RandomAccessFile raf = new RandomAccessFile(file,"rwd");
raf.seek(file.length()-1); // Set the pointer to the end of the file
System.err.println("MSR:: RandomAccessFileDemo :: the file pointer is"+raf.getFilePointer());
raf.setLength(raf.length()-raf.length());
}
}