posted 16 years ago
This is my code and it is getting to end of file exception .The file is found and it is getting the pointer but not reading anything . Can yout ell how to get the cookie and other feilds. Please help. thanks
File datafile = new File("db-2x3.db");
RandomAccessFile in = null;
try { in = new RandomAccessFile(datafile, "r");
System.out.println("file found");
} catch (FileNotFoundException e) { System.out.println("FNF: " + e.getMessage());
System.exit(1); }
try { // Read the file header
in.seek(8);
System.out.println("FILE HEADER\n===========");
System.out.println ("Pointer is at333a " + in.readInt());
int datafileId = in.readInt();
System.out.println("Magic Number: 0x" + Integer.toHexString(datafileId));
int recZeroOffset = in.readInt();
System.out.println("Record 0 Offset: " + recZeroOffset);
short fieldsPerRec = in.readShort();
System.out.println("Fields per Record: " + fieldsPerRec + "\n");
} catch (EOFException e) { System.out.println("EOF: " + e.getMessage()); }
catch (IOException e) { System.out.println("IO: " + e.getMessage()); }
finally { try { in.close(); } catch (Exception e) {} }
}
}