I can give you some code, to the best of my ability -- I am at home remebering
this.  But if you are using a servlet, then the servlet will be in memory when you
are changing the text file, and the changes won't take effect until you restart
the server.  If that is the case, you might want to code it into the servlet.
However, you are closer to the problem then I.

[OUTPUT]
FileOutputStream f = new FileOutputStream("FILEPATH");
PrintStream out = new PrintStream(f);

The input version is very similar and starts with:

FileInputStream f = new FileInputStream("FILEPATH");
[something] in = new [something(f)];

Sorry it is so scetchy,

DanC

YekSoon Lok wrote:

> Hi,
>
> I have code a servlet that can connect to the database.
> But I find my design not good enough.
>
> The main reason is because the connection string is coded
> inside. Should I change database or database instance,
> I would need to change the code and recompile the source.
>
> I'm thinking of putting the connection string in a text file
> and have my servlets access this file and read it in.
> This way all I need is to change the text file or initialization
> file and my class file remains the same.
>
> Does anyone have any snippets of code where I can learn how
> to read from a file ?
>
> Another area, is if I use a file for initilization purpose,
> I will have lots of sections. Examples are section for connection string,
> for constants (maybe) etc.
> Whats the best way to use a text file for init. purpose.
>
> Thanks
> ----------
> Message To Spammers -- Game Over!  Get spam-free email at http://www.MsgTo.com
>
> ___________________________________________________________________________
> 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