Reputation: 5989
We are working on project. Every colleague have different folder for the install In my case the folder of my files is in
C:\\p4_3202\\CAR\\car.rt.appl\\dev\\car.components\\cars\\res\\car.rt.components.cars\\resources\\js;
for other colleague it could be in
C:\\my_3202\\CAR2\\car.rt.appl\\dev\\car.components\\cars\\res\\car.rt.components.cars\\resources\\js;
it is depends how you config your perforce.
I need to read files from my folder but i don't know the name of the folder ( as i explained it could be different )
File folderFile = new File(folder);
How i can find the location of my folder ? ( c:\p4\......test.js ) I tried with
System.getProperty("sun.java.command");
System.getProperty("user.home")
but it didn't give me the path of my folder
Upvotes: 1
Views: 132
Reputation: 6173
I would use a system property for each user. So all users tell where perforce is installed (might already exist a property for this, look at the docs). This could then be read by your code like:
System.getenv().get("PROP");
On a unix/Linux system you can set the property in a shell/environment variable using:
export PROP=thepath
Windows was a long time ago for me but if I remember correctly its somewhere under System on control panel :)
Update: http://www.itechtalk.com/thread3595.html
Upvotes: 1
Reputation: 109547
If it are files for reading only, being stored inside the final produced jar, then use URL url = getClass().getResource("/.../...")
or InputStream in = getClass().getResourceAsStream("/.../...")
.
That uses a path inside the jar/class path. Using only the jar would never do with File.
Upvotes: 0