如题:
StringWriter sw=new StringWriter();
sw.write("aa");
System.out.println("1:"+sw);
sw.flush();
System.out.println("2:"+sw);
两处都有结果,flush后缓存没有清空吗?
如题:
StringWriter sw=new StringWriter();
sw.write("aa");
System.out.println("1:"+sw);
sw.flush();
System.out.println("2:"+sw);
两处都有结果,flush后缓存没有清空吗?
找到了,
public void flush() {
}
Flush is suppose to ensure that all characters written to the Writer are
fully processed. For example, if the Writer were outputting to a
terminal, calling flush would ensure that all characters appeared on the
screen. Since StringWriter doesn't do any buffering (that is, it
updates its internal buffer on every write), flushing it is a no-op.