假设系统的路径为:E:\Program Files\myworkspace\EngravedCode
(1)System.out.println(System.getProperty("user.dir"));//user.dir指定了当前的路径
输出:E:\Program Files\myworkspace\EngravedCode
(2)File directory = new File("");//设定为当前文件夹
try {
System.out.println(directory.getCanonicalPath());
System.out.println(directory.getAbsolutePath());//获取绝对路径
} catch (IOException e) {
e.printStackTrace();
}