Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-23-2007, 05:06 PM
Member
 
Join Date: Dec 2007
Location: KSA, Riyadh
Posts: 9
AralX is on a distinguished road
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 09:08 PM. Reason: Updating
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-23-2007, 09:20 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 12-25-2007, 09:04 PM
Member
 
Join Date: Dec 2007
Location: KSA, Riyadh
Posts: 9
AralX is on a distinguished road
Quote:
I 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

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)
the line 81 is

Code:
setRecordnumber(datafile.readInt()); setToolName(StringModifierReader(datafile)); setQuantity(datafile.readInt()); setCost(datafile.readDouble());
and from a website it says that this Kind of exception when Occures with readInt() of the RAF
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
has been solved just now incase you are woundering... the file was Empty, thats why

thanks everyone

Last edited by AralX : 12-25-2007 at 11:18 PM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
mail concept indirani New To Java 3 04-16-2008 03:30 PM
random numbers without random class` carlos123 New To Java 4 01-18-2008 12:44 AM
Random Access File JavaForums Java Blogs 0 12-26-2007 04:01 PM
Help with access a database using Microsoft Access cachi Database 1 08-07-2007 09:51 AM
access to dll files Heather Advanced Java 1 07-08-2007 02:30 AM


All times are GMT +3. The time now is 02:40 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org