# BufferedWriter constructor

BufferedWriter(

1. Writer writer, {
2. int bufferSize = _defaultBufferSize,

})

Creates a buffering character-output stream that uses a default-sized output buffer.

## Parameters

- `writer`: The underlying character writer
- `bufferSize`: The buffer size (default: 8192 characters)

## Example

    final buffered = BufferedWriter(FileWriter('output.txt'));
    final largeBuffered = BufferedWriter(
      FileWriter('large_output.txt'),
      bufferSize: 65536
    );

Writes text to a character-output stream, buffering characters to provide efficient writing of characters, arrays, and strings.

The buffer size may be specified, or the default size may be used. The default is large enough for most purposes.

## Example Usage

    // Basic buffered writing
    final buffered = BufferedWriter(FileWriter('output.txt'));
    try {
      await buffered.write('Hello, World!');
      await buffered.writeLine('This is a new line.');
      await buffered.flush();
    } finally {
      await buffered.close();
    }

    // Writing large amounts of data efficiently
    final buffered = BufferedWriter(FileWriter('large_output.txt'), bufferSize: 65536);
    try {
      for (int i = 0; i < 10000; i++) {
        await buffered.writeLine('Record $i: ${generateLargeString()}');
      }
      await buffered.flush();
    } finally {
      await buffered.close();
    }

## Implementation

    BufferedWriter(Writer writer, {int bufferSize = _defaultBufferSize})
        : _writer = writer,
          _buffer = List<int>.filled(bufferSize, 0);