1.Java获取系统桌面路径 

FileSystemView fsv = FileSystemView.getFileSystemView(); 
 File com = fsv.getHomeDirectory();//获取桌面路径的具体方法。
File TargetFile = new File(fsv.getHomeDirectory().getPath() + "/user/");//创建新的路径

2.Java设定文件路径 

# 至于getPath()函数,得到的只是你在new File()时设定的路径

比如当前的路径为 C:/test :

File directory = new File("abc");
directory.getCanonicalPath(); //得到的是C:/test/abc
directory.getAbsolutePath(); //得到的是C:/test/abc
direcotry.getPath(); //得到的是abc
File directory = new File(".");
directory.getCanonicalPath(); //得到的是C:/test
directory.getAbsolutePath(); //得到的是C:/test/.
direcotry.getPath(); //得到的是.
File directory = new File("..");
directory.getCanonicalPath(); //得到的是C:/
directory.getAbsolutePath(); //得到的是C:/test/..
direcotry.getPath(); //得到的是..