Storing classes in a RandomAccessFile

J

jpshahom

How can I save to disk the various names of classes into a
RandomAccess File?
My objective is to assign the value of primitives which I'll be
reading from disk to differently named classes
 
A

Anthony Borla

Before specifically answering your questions I'd like to point out [on the
off chance you don't already know] that Java supports a form of object
serialisation [i.e. the converting of objects to storable / transmittable
form, so allowing them to be later recreated]. This *may* be what you may
actually require. For more details on its use, see:

http://java.sun.com/docs/books/tutorial/essential/io/serialization.html

Ok, now to your questions:
How can I save to disk the various names of classes into a
RandomAccess File?

Class names are 'String' types, so you would probably use the 'readUTF' and
'WriteUTF' methods to read / write this data.
My objective is to assign the value of primitives which I'll be
reading from disk to differently named classes

This is easily accomplished using the relevant method [e.g. 'writeDouble',
'readDouble' etc]. However, you are, of course, referring to reading /
writing data pertaining to *objects*, are you not ? Again, it sounds like a
need for object serialisation [though I hope I've not misunderstood your
question].

I hope this helps.

Anthony Borla
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top