在Java程序(Java 1.5)中,我有一个包装文件编写器的BufferedWriter,我多次调用write()...生成的文件非常大...
在这个文件的行中,有些是不完整的......
每次写东西时我是否需要调用flush(但我怀疑它效率低下)或者使用BufferedWriter的另一种方法或者使用另一个类......?
(因为我写了很多行,我确实希望有一些非常有效的东西.)理想的"潮红"时刻是什么?(当我达到BufferedWriter的容量时)......
在里面:
try {
analysisOutput = new BufferedWriter(new FileWriter(
"analysisResults", true));
analysisOutput.newLine();
analysisOutput.write("Processing File " + fileName + "\n");
}
catch (FileNotFoundException ex) {
ex.printStackTrace();
}
catch (IOException ex) {
ex.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
写作:
private void printAfterInfo(String toBeMoved,HashMap<String, Boolean> afterMap, Location location)
throws IOException {
if(afterMap != null) {
for (Map.Entry<String, Boolean> map : afterMap.entrySet()) {
if (toBeMoved == "Condition") {
if (1 <= DEBUG)
System.out.println("###" + toBeMoved + " " + location + " "
+ …
Run Code Online (Sandbox Code Playgroud)