import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; public class FileLengthExample { public static void main(String[] args) { File file = new File("example.txt"); try { RandomAccessFile raf = new RandomAccessFile(file, "r"); System.out.println("File length in bytes: " + raf.length()); raf.close(); } catch (IOException e) { e.printStackTrace(); } } }In this example, we create an instance of the RandomAccessFile class and pass the file "example.txt" as an argument to the constructor. We then call the length() method on the RandomAccessFile object to print the length of the file in bytes. Package library: The RandomAccessFile class is part of the java.io package, which is a part of the Java Standard Library.