Package org.aoju.bus.core.io.file
Class FileAppender
java.lang.Object
org.aoju.bus.core.io.file.FileAppender
- All Implemented Interfaces:
Serializable
文件追加器 持有一个文件,在内存中积累一定量的数据后统一追加到文件 此类只有在写入文件时打开文件,并在写入结束后关闭之 因此此类不需要关闭
在调用append方法后会缓存于内存,只有超过容量后才会一次性写入文件,因此内存中随时有剩余未写入文件的内容,在最后必须调用flush方法将剩余内容刷入文件
- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionFileAppender(File destFile, int capacity, boolean isNewLineMode) 构造FileAppender(File destFile, Charset charset, int capacity, boolean isNewLineMode) 构造FileAppender(File destFile, Charset charset, int capacity, boolean isNewLineMode, Lock lock) 构造 -
Method Summary
-
Constructor Details
-
FileAppender
构造- Parameters:
destFile- 目标文件capacity- 当行数积累多少条时刷入到文件isNewLineMode- 追加内容是否为新行
-
FileAppender
-
FileAppender
-
-
Method Details
-
append
-
flush
-