Rajendran, Rajarajan wrote:
>
> Well, I did that. Anyway thank you.
>
> I have a different but related doubt. You can only read key-value pairs
> from a properties file. In case if there are two or three simple values
> (instead of just one in properties file) for every key, how can you store
> and read from a simple file (possibly a text file ?) (without going for
> tables/database). This has to be loaded in a right data structure and has
> to be retrieved.
>
> Say for example, id=1,kevin,23
>                  id=2,mukar,32
>
> Please tell me the following approach is right ?
>
> Read it as a properties file and after that by using StringTokenizer "," ,
> we can get the individual values.

The approach you described should almost work. In the example above,
'id' is the property name and '1,kevin,23' would be a value. You can't
use 'id' again as a property name. But assuming you used different
property names, a value can be any string.

It appears that you want to keep properties for individual users. One
solution would be to set up the property file like this:

id=1,2,3,4
name1=kevin
prop1=23
name2=mukhar
prop2=32
name3=rajendran
prop3=45
name4=kumar
prop4=56

You create the property object then retrieve the id property. Parse
through the string of id's and programmatically create the strings to
retrieve the other properties. Of course, with a lot of users, this
could get to be a big mess.

Another technique would be to create a property file for each user. Then
create a property file that stores the name of the property file for
each user. Create a property object to get the names of the required
property file and figure out which key-value pair you need for a
particular user. Using the value, open the property file for that user
and get the properties for that user.

You could also just create one or more text files to store the
information. Open and read the text file as needed.

You could create an object that represents the properties for a user.
Serialize the object to a data file that you can uniquely connect to a
particular user. When you need the properties again, recreate the object
from the serialized file.

There are probably other ways to do what you want to do. I think the
property file approach you are trying to take will work, once you get
the details straight.

Kevin Mukhar

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to