我使用java创建了文件,代码如下
String Filecontent= "hei";
创建文件
PrintWriter writer=new PrintWriter("D://balanworkspace//Coretest//Corejavatest//src//intvquestest//mydet3_8.txt","UTF-8");
打印字符串
System.out.println(Filecontent);
写入文件
writer.println(Filecontent);
当我打开文件时,没有任何值。为什么会这样?
最佳答案
您需要通过执行以下操作来关闭PrintWriter
:
writer.close();
关于java - 使用java创建文件后,其中没有值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36709237/