import java.io.File;
/**
* JAVA得到当前程序的绝对路径
*
* @author JAVA世纪网(java2000.net)
*
*/
public class Test {
public static void main(String[] args) {
System.out.println(getPath());
System.out.println(getPath2());
}
/**
* 通过文件得到当前绝对路径
*
* @return
*/
public static String getPath() {
File f = new File("");
try {
return f.getAbsolutePath();
} finally {
f = null;
}
}
/**
* 从系统变量得到当前绝对路径
*
* @return
*/
public static String getPath2() {
return System.getProperty("user.dir");
}
}