Results 1 to 3 of 3
Thread: Random Access Files concept
- 12-23-2007, 03:06 PM #1
Member
- Join Date
- Dec 2007
- Location
- KSA, Riyadh
- Posts
- 9
- Rep Power
- 0
Random Access Files
Hey 'all !
******************************************
-------------------updated---------------------------------
- what is below the Update blockis answered-
~New -go to postNumber 3 , there is myQuestion-
******************************************
how is everyone ?
I want to get to under stand the concept .. of Random access files
now , that I have a file and and initialized an Object of a RandomAccessFile class .. in the form of "rw" (Read/write) ...here i can write and read randomly .. but can I Edit randomly .. like delet a file then replace it with a new data ?
thanks :)Last edited by AralX; 12-25-2007 at 07:08 PM. Reason: Updating
- 12-23-2007, 07:20 PM #2
but can I Edit randomly .. like delet a file then replace it with a new data ?
Yes. The RandomAccessFile class api has methods for navigating within the raf, reading and writing. You also have String methods available. Here's an older article about RandomAccessFiles: JDC Tech Tips: May 09, 2000.
- 12-25-2007, 07:04 PM #3
Member
- Join Date
- Dec 2007
- Location
- KSA, Riyadh
- Posts
- 9
- Rep Power
- 0
has been solved just now incase you are woundering... the file was Empty, thats why :DI don't want to Open a new thread , so I'd reather post my Question here aslong as it is related ..
when reading from a RAF .i found this exception
the line 81 isJava Code:at java.io.RandomAccessFile.readInt(Unknown Source) at HardwareRecord.readRecord(HardwareRecord.java:81) at HardwareStoreInventory.getRecordFileandCheck(HardwareStoreInventory.java:33) at HardwareStoreInventory.AddFile(HardwareStoreInventory.java:12) at testerProg.RunOption(testerProg.java:66) at testerProg.RunApplication(testerProg.java:18) at Application.main(Application.java:19)
and from a website it says that this Kind of exception when Occures with readInt() of the RAFJava Code:setRecordnumber(datafile.readInt()); setToolName(StringModifierReader(datafile)); setQuantity(datafile.readInt()); setCost(datafile.readDouble());
is usuallu because that it reached the eand of the file before 4 Bytes .. or something like that
but I have calculated the File length correctly
4 Bytes(Int)* 2(I have two)= 8
8Bytes(Double)*1 = 8 +
30Bytes(String of 15Chars)=30+
-------------------------------------------
the Total is 46
which will be the size of each file right ?
what do you people suggest me to do in order to handle the Exception ?
Thanks again :)
thanks everyoneLast edited by AralX; 12-25-2007 at 09:18 PM.
Similar Threads
-
mail concept
By indirani in forum New To JavaReplies: 3Last Post: 04-16-2008, 01:30 PM -
random numbers without random class`
By carlos123 in forum New To JavaReplies: 4Last Post: 01-17-2008, 10:44 PM -
Help with access a database using Microsoft Access
By cachi in forum JDBCReplies: 1Last Post: 08-07-2007, 07:51 AM -
access to dll files
By Heather in forum Advanced JavaReplies: 1Last Post: 07-08-2007, 12:30 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks