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.

Is there any other better approach ?

Regards

Raj
-----Original Message-----
From: Kevin Mukhar [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 26, 2000 11:31 AM
To: [EMAIL PROTECTED]
Subject: Re: properties file to Hashtable.


"Rajendran, Rajarajan" wrote:
>
> I want to read a .properties file through a servlet and get the properties
> and
> set it to a Hashtable. Can anyone please help me out by sample code.

Have you read the javadoc for Properties and Hashtable yet? Normally that
should
be enough to answer your question. If you have read the docs, are you having
a
specific problem?

First create property file using an editor

Here's pseudo code showing one way to get properties:

create instance of java.io.FileInputStream from property file
create instance of java.util.Properties
call Properties.load(InputStream) method to load properties
call Properties.propertyNames() to get Enumeration of all names
loop through Enumeration of names
  call getProperty(name) to get a property
  if you really want to, store name/property in hashtable

Why are you wanting to store the properties in a Hashtable? Since the
Properties
class already stores properties for you using a key-value approach, creating
a
Hashtable to store the properties is redundant.

K 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

___________________________________________________________________________
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