如何在不关闭BufferedWriter的情况下访问文件中的数据?
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class Tp {
public static void main(String[] args) throws IOException{
File f = new File("Store.txt");
BufferedWriter bw = new BufferedWriter(new FileWriter(f));
BufferedReader br = new BufferedReader(new FileReader(f));
bw.write("Some text");
System.out.println(br.readLine());
bw.write("Some more text");
bw.close();
br.close();
}
}
控制台显示为空。我该如何解决这个问题?
flush()
清空写入器。 - XtremeBaumer