Java IO Tutorial - Java FilterWriter.close()








Syntax

FilterWriter.close() has the following syntax.

public void close()  throws IOException

Example

In the following code shows how to use FilterWriter.close() method.

import java.io.FilterWriter;
import java.io.StringWriter;
import java.io.Writer;
//from  w w  w. ja v  a 2s  .  c o  m
public class Main {
  public static void main(String[] args) throws Exception {

    Writer w = new StringWriter(6);

    FilterWriter fw = new FilterWriter(w) {};

    fw.write(65);

    String s = w.toString();

    System.out.println(s);

  }
}

The code above generates the following result.