Methods of OutputStream

The OutputStream class provides different methods that are implemented by its subclasses. Here are some of the methods

  1. write() - writes the specified byte to the output stream.
  2. write(byte[] array) - writes the bytes from the specified array to the output stream.
  3. flush() - forces to write all data present in output stream to the destination.
  4. close() - closes the output stream.

Here is how we can implement OutputStream using the FileOutputStream class.


\begin{lstlisting}
import java.io.FileOutputStream;
import java.io.OutputStream;...
...e();
}
\par
catch( Exception e) {
e.getStackTrace ();
}
}
}
\end{lstlisting}