Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2006

Tip: Looking for answers? Try searching our database.

Java property files

Thread view: 
KenStahl - 08 Oct 2006 03:40 GMT
I have a java application that reads a properties file. All
is well until I include a property like:

AppPath = C:\Program files\myprog\dat

When I use getProperty() to read the property the \
characters are stripped out.

How can I prevent this from happening to that the string
reads in correctly?

Signature

If you can't be the flame, don't be the moth.

Lew - 08 Oct 2006 20:18 GMT
> I have a java application that reads a properties file. All is well
> until I include a property like:
[quoted text clipped - 6 lines]
> How can I prevent this from happening to that the string reads in
> correctly?

Read
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html#load(java.io.I
nputStream
)

It explains how the backslash character '\' is interpreted.

- Lew
KenStahl - 08 Oct 2006 22:15 GMT
>> I have a java application that reads a properties file. All is well
>> until I include a property like:
[quoted text clipped - 13 lines]
>
> - Lew

That is all well and fine. I knew WHAT was happening. I just
need to know how to prevent it from happening?

Is my only resort to use StringTokerizer?

Signature

If you can't be the flame, don't be the moth.

Lew - 08 Oct 2006 22:46 GMT
>>> I have a java application that reads a properties file. All is well
>>> until I include a property like:
[quoted text clipped - 6 lines]
>>> How can I prevent this from happening to that the string reads in
>>> correctly?

>> Read
>> http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html#load(java.io.I
nputStream
)
[quoted text clipped - 7 lines]
>
> Is my only resort to use StringTokerizer?

As explained in the link, you can double the backslashes.

Or use forward slashes.

Read the link.

- Lew
KenStahl - 08 Oct 2006 23:10 GMT
>>>> I have a java application that reads a properties file. All is well
>>>> until I include a property like:
[quoted text clipped - 26 lines]
>
> - Lew

Ok, I wasn't clear on something and I should have been. The
property file is not controlled by my application so I have
to accept it in its present form. Obviously the people who
wrote the controlling application know what they did to get
around the problem but I don't have access to them.

Signature

If you can't be the flame, don't be the moth.

KenStahl - 08 Oct 2006 23:04 GMT
>> I have a java application that reads a properties file. All is well
>> until I include a property like:
[quoted text clipped - 13 lines]
>
> - Lew

That is all well and fine. I knew WHAT was happening. I just
need to know how to prevent it from happening?

Is my only resort to use StringTokerizer?

Signature

If you can't be the flame, don't be the moth.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.