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

    原文作者:weixin_30337251
    原文地址: https://blog.csdn.net/weixin_30337251/article/details/96940370
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞