java输出txt文件到桌面

private static void outputTxt(String ExportFailStudentMsg){
FileSystemView fsv = FileSystemView.getFileSystemView();
File com=fsv.getHomeDirectory();
System.out.println(com.getPath());
File f=new File(com.getPath()+"\failmsg.txt");
FileOutputStream fos;
try {
fos = new FileOutputStream(f);
OutputStreamWriter dos=new OutputStreamWriter(fos);
dos.write(ExportFailStudentMsg);
dos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}

原文地址:https://www.cnblogs.com/it66/p/10981182.html