Forums Register Login

Relative File() path?

+Pie Number of slices to send: Send
Hey JavaGurus!

A quick and easy question for those of you who feel at home with the File object.

When I use an absolute file path everything works just as expected:


But what I need is a relative file path.
When I try to implement this using the following code:


It doesnt work at all.
Why?
What is it that Im missing?

Thanks in advance and have a great summer!

Kind regards
[ July 16, 2007: Message edited by: Dominic Steng�rd ]
+Pie Number of slices to send: Send
The path will be relative to the current working directory, the current directory when the process was launched. You're probably expecting something else. Try calling getAbsolutePath() on your File object to see how your path is being interpreted.
+Pie Number of slices to send: Send
Thank you Ernest!

You were so right ... calling getAbsolutePath() on the file object gave me a totally different relative path than I had expected.
My code runs just fine now.
A timing clock, fuse wire, high explosives and a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1454 times.
Similar Threads
Writting a String to a file
Need your help about a File Quesion.(scjp03-Q90)
Relative Addressing for .txt Files
specify relative path in File constructor
session null
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 21:28:51.