Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can't read database

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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) {} }
}
}
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Please do not repost simply because you did not get a reply in your other topic. Continue in your original topic.
 
There’s no place like 127.0.0.1. But I'll always remember this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
    Bookmark Topic Watch Topic
  • New Topic