Re: help with properties class
- From: "Andrew Thompson" <andrewthommo@xxxxxxxxx>
- Date: 28 Feb 2007 01:01:38 -0800
On Feb 28, 6:17 pm, divyatiwari...@xxxxxxxxx wrote:
What am I doing wrong in this program??
Good question.
//////////////////////...
(Note these big long lines are not needed,
most people expect code to be enclosed in
just <code> .. </code> or <sscce> .. <sscce>
or similar.)
import java.util.Properties;...
There are a number of problems with
this code sample, the first of which
you identify in the output.
I'm getting the following errors:
PropEg.java:13: illegal escape character
p.setProperties("path,C:\Program Files\Java\jdk1.6.0\bin");
^
PropEg.java:13: illegal escape character
Java regards '\' as an 'escape' character,
to indicate the next character should be
treated in a special way. For example..
'\n' will cause a new line in a text area,
or '\t' will cause a 'tab'.
In order to get a '\', you need to tell
Java that you really *mean* a '\' and the
way to do that is '\\' - put two of them.
That way, Java knows you actually mean
simply '\'.
Note that when it comes to paths, using
hard coded file separator characters
(the '\') causes cross-platform problems.
That might not be important to this code,
but I think it would be worth investigating
why you believe your application needs to
set this property, as well as the entire
way you are doing it.
(Oh, and the second problem is that method
requires two arguments of type string, and
is singular, but more later.. ;)
Andrew T.
.
- Follow-Ups:
- Re: help with properties class
- From: Andrew Thompson
- Re: help with properties class
- References:
- help with properties class
- From: divyatiwari123
- help with properties class
- Prev by Date: Re: EMPTY_SET.iterator() and generics
- Next by Date: Re: help with properties class
- Previous by thread: help with properties class
- Next by thread: Re: help with properties class
- Index(es):