File()

C

Crouchez

If I put new File("/folder/file") is that root to whichever drive the main
java prog was loaded or root to the operating system or root to where the
JVM is located? eg. I load a java prog from w:/java/myprog.java - will root
be w:/ or c:/ (typical windows drive)?
 
S

Stefan Ram

Crouchez said:
If I put new File("/folder/file") is that root to whichever drive the main

If it is not specified in the API documentation of
»java.io.File« or the JLS, one must assume that it is an
implementation specified property, i.e., that this depends on
the JVM chosen to execute the program (including the
environment, i.e., the hosting operating system and its
configuration and the hardware available).

Then, to learn how a specific Java implementation behaves,
you can try it out.

Don't use such paths fixed in the source code, but put the
path prefix into a configuration file or the application
properties, so that the user can change it according to his
environment, or use one of the paths that are preconfigured in
Java, such as »user dir« (even though »user dir« is not what
the name might suggest).
 

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

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top