Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想使用apache common-io包,但是我不确定写/读函数中是否有任何缓冲策略。 例如,在 FileUtil 类中有如下函数
static void write(File file, CharSequence data);
如果每次调用这些函数都遵循 open->read/write->close,效率会很低。我相信一定有一些缓冲策略,对吧?
程
它不会缓存打开的文件,否则您可能会面临文件句柄用完的风险,或者因为文件处于打开状态而无法重命名/删除文件。
它使用了一些缓冲,但是当 write() 返回时,您可以期望文件被关闭。