@@ -110,7 +110,7 @@ public Builder() {
110110 */
111111 @ Override
112112 public DeferredFileOutputStream get () {
113- return new DeferredFileOutputStream (threshold , outputFile , prefix , suffix , directory , getBufferSize () );
113+ return new DeferredFileOutputStream (this );
114114 }
115115
116116 /**
@@ -322,22 +322,15 @@ public DeferredFileOutputStream(final int threshold, final int initialBufferSize
322322 /**
323323 * Constructs an instance of this class which will trigger an event at the specified threshold, and save data either to a file beyond that point.
324324 *
325- * @param threshold The number of bytes at which to trigger an event.
326- * @param outputFile The file to which data is saved beyond the threshold.
327- * @param prefix Prefix to use for the temporary file.
328- * @param suffix Suffix to use for the temporary file.
329- * @param directory Temporary file directory.
330- * @param initialBufferSize The initial size of the in memory buffer.
331- * @throws IllegalArgumentException if initialBufferSize < 0.
325+ * @param builder The construction data source.
332326 */
333- private DeferredFileOutputStream (final int threshold , final Path outputFile , final String prefix , final String suffix , final Path directory ,
334- final int initialBufferSize ) {
335- super (threshold );
336- this .outputPath = toPath (outputFile , null );
337- this .prefix = prefix ;
338- this .suffix = suffix ;
339- this .directory = toPath (directory , PathUtils ::getTempDirectory );
340- this .memoryOutputStream = new ByteArrayOutputStream (checkBufferSize (initialBufferSize ));
327+ private DeferredFileOutputStream (final Builder builder ) {
328+ super (builder .threshold );
329+ this .outputPath = toPath (builder .outputFile , null );
330+ this .prefix = builder .prefix ;
331+ this .suffix = builder .suffix ;
332+ this .directory = toPath (builder .directory , PathUtils ::getTempDirectory );
333+ this .memoryOutputStream = new ByteArrayOutputStream (checkBufferSize (builder .getBufferSize ()));
341334 this .currentOutputStream = memoryOutputStream ;
342335 }
343336
0 commit comments