Question: the java code below is supposed to read a raf file with 10 ints in it from back to front. I keep getting a eofException
the java code below is supposed to read a raf file with 10 ints in it from back to front. I keep getting a eofException every time i try to run it. where am i going wrong? any raf file of ints can be used.
import java.io.IOException; import java.io.RandomAccessFile; public class FileRead {
public static void main(String[] args) throws IOException{ int x; RandomAccessFile file = new RandomAccessFile("c:\\Users\\jess\\Desktop\\data.raf","r"); for(int i = 0; i < (file.length()/4); i ++ ){ file.seek(file.length() - (i*4)); x = file.readInt(); System.out.println(x); } } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
