出于某种原因,我的字符串部分由PrintWriter写入。因此我在文件中获得了部分文本。这里的方法:PrintWriter只写部分文本
public void new_file_with_text(String text, String fname) {
File f = null;
try {
f = new File(fname);
f.createNewFile();
System.out.println(text);
PrintWriter out = new PrintWriter(f, "UTF-8");
out.print(text);
} catch (IOException e) {
e.printStackTrace();
}
}
哪里打印文本到控制台,我可以看到的数据都在那里,没有什么损失,但显然文本的一部分时丢失的PrintWriter,它的工作......我无能..
...或在'finally'块中,以及'out.close()'! –