• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Random Access File

 
Jason Marshall
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

Are there cases when methods to not fire on RandomAccessFile?

What I am trying to do is add a new Room to my database with the create method!

The below code writes to the database.


I can confirm that I have found the first deleted record. I then proceed to change the deleted char from 0X0000 to 0X00 (Valid).

I can confirm that database.write(out.toString().getBytes()); gets written to the database but database.writeChar(Room.VALID_RECORD); never does.

This is really really weired! Are there known cases why this does not happen?

The problem is that since the Value never changes from deleted, no new Room is ever added.

Please let me know if I can provide more information, I'm so frustrated with this bl0$dy assignment.

thanks,

Jason
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jason,

I guess it all depends on how big the delete flag is. In my assignment the flag was 1 byte.

So i was able to successfully write my delete flag with the following code:

Kind regards,
Roel
 
Jason Marshall
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel De Nijs wrote:Hi Jason,

I guess it all depends on how big the delete flag is. In my assignment the flag was 1 byte.

So i was able to successfully write my delete flag with the following code:

Kind regards,
Roel


Hey bud,

Thanks for the fast reply. I just tried that and still no Joy, it seemed to put everything out by 1 place. I then added offest + 1 and it still did not change

Cheers
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jason,

How big is your delete flag according to your instructions? What's the declaration for your Room.VALID_RECORD ?

[edit] I guess your delete flag is 2 bytes, so you would use writeShort and readUnsignedShort for the reading/writing of your deleted flag. More info about this in this thread.

Kind regards,
Roel
 
Jason Marshall
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel De Nijs wrote:Jason,

How big is your delete flag according to your instructions? What's the declaration for your Room.VALID_RECORD ?

[edit] I guess your delete flag is 2 bytes, so you would use writeShort and readUnsignedShort for the reading/writing of your deleted flag. More info about this in this thread.

Kind regards,
Roel


Thanks Roel,

Yes my flag is 2 bytes. I originally did have it as wrtiteShort.

I'll check out the thread now thanks
 
Jason Marshall
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No matter what I do I cannot change the stupid flag ( )

I have used writeShort(00), writeShort(0X00), writeChar(00)

Everything.

why oh why...
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jason,

How are you checking if the deleted flag is changed? With Roberto's program or with some self-written file reader? Or just with your program?

Otherwise you just have to submit some chuncks of code (only the appropriate ones, not your whole create-method, because that's not allowed) to see that you didn't make a mistake elsewhere (maybe a wrong calculation of the offset for example).

Kind regards,
Roel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic