| Refresh | Home EGTry.com

set the current working directory


CurrentDir.java

package egtry.file;

import java.io.File;

public class CurrentDir {


	public static void main(String[] args) {

		File file=new File("test.txt");
		System.out.println("absolute path:"+file.getAbsolutePath());
		System.setProperty("user.dir", "C:\\work");
		System.out.println("absolute path:"+file.getAbsolutePath());

	}

}


Output

absolute path:C:\my1\projects\JavaAppEngine\ConsoleExample\test.txt
absolute path:C:\work\test.txt