Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-02-2012, 06:22 AM   PM User | #1
gizmo1650
Regular Coder

 
Join Date: Apr 2010
Posts: 163
Thanks: 3
Thanked 25 Times in 25 Posts
gizmo1650 is on a distinguished road
File paths inconsistent after changing working directory

I am trying to change my working directory. To that end I created the following test program
Code:
import java.io.File;
public class foo {
	public static void main(String[] args) {
		System.setProperty("user.dir","/");
		String foo="bar";
		System.out.println((new File(foo).exists()));
		foo=(new File(foo)).getAbsolutePath();
		System.out.println((new File(foo)).exists());
	}
}
When /bar exists, the output of this program is
Code:
false
true
When the file exists in the default working directory, and not in the new one, the output is
Code:
true
false
When it exists in neither it is
Code:
false
false
When it exists in both it is
Code:
true
true
I am modifying an already written program, and if possible would like to avoid changing every file-system call.
__________________
take a point P, now call it Q.
gizmo1650 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:50 PM.


Advertisement
Log in to turn off these ads.