路径获取
String path=System.getProperty("user.dir");
System.out.println(path);//user.dir指定了当前的路径
path = path.substring(0,path.lastIndexOf("\\"));
System.out.println(path);
File directory = new File(path+"\\test.log");//设定为当前文件夹
FileOutputStream fos=new FileOutputStream(directory.getAbsolutePath(),true);
fos.write("nihaonihao".getBytes());
fos.flush();
fos.close();
try {
System.out.println(directory.getCanonicalPath());//获取标准的路径
System.out.println(directory.getAbsolutePath());//获取绝对路径
} catch (IOException e) {
e.printStackTrace();
}