Java IO Tutorial - Java FilterOutputStream.close()








Syntax

FilterOutputStream.close() has the following syntax.

public void close()  throws IOException

Example

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

/*  w w  w .j  a v a 2s. co  m*/
import java.io.FileOutputStream;
import java.io.FilterOutputStream;
import java.io.OutputStream;

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

    // create input streams
    OutputStream os = new FileOutputStream("C://test.txt");
    FilterOutputStream fos = new FilterOutputStream(os);

    // releases any system resources associated with the stream
    fos.close();

    // writes byte to the output stream
    fos.write(65);

  }
}