java.io and user.dir

B

Benji

The comments in the File javadoc state the following:

By default the classes in the java.io package always resolve relative
pathnames against the current user directory. This directory is named
by the system property user.dir, and is typically the directory in which
the Java virtual machine was invoked.

Now, I've seen several old threads on various forums asking why user.dir
is read-only, and I believe there was a feature request put in for allowing
user.dir to be modifiable. So, I checked to see if I could set it, and
it turns out I can. And, in fact, if I create a new File like
new File("tmp.txt"), the absolute path name gets changed based on what I
set user.dir to.

However, it seems that at least the native method "open" in FileInputStream
does not use the system property "user.dir". So, my question is, is this
an impossible task? Or is there something else I need to do besides
System.setProperty("user.dir");
 
B

Benji

Benji said:

Well, I'm going to answer my own question and say "don't do it".

apparently as of fairly recently, they've resolved to not fix this at
any point in the near future. (although, I think that making a setProperty
call on "user.dir" fail in some way would be most helpful. =P)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,120
Latest member
ShelaWalli
Top