Java BufferedWriter.write(int c)

Syntax

BufferedWriter.write(int c) has the following syntax.

public void write(int c)  throws IOException

Example

In the following code shows how to use BufferedWriter.write(int c) method.


/*from  w w  w . j  a v  a  2s  . c  om*/

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.StringWriter;

public class Main {
  public static void main(String[] args) throws IOException {

    StringWriter sw = new StringWriter();

    BufferedWriter bw = new BufferedWriter(sw);

    for (int i = 65; i <= 90; i++) {
      bw.write(i);
    }

    bw.flush();

    StringBuffer sb = sw.getBuffer();

    System.out.println(sb);

  }
}

The code above generates the following result.