OutputStream

In this chapter you will learn:

  1. How to use OutputStream

Use OutputStream

Byte streams are defined by using two class hierarchies. At the top are two abstract classes: InputStream and OutputStream.

OutputStream class is the superclass of all classes representing an output stream of bytes. An output stream accepts output bytes and sends them to some sink. Applications that need to define a subclass of OutputStream must always provide at least a method that writes one byte of output.

The following table lists the output streams.

Stream ClassMeaning
OutputStreamAbstract class that describes stream output
BufferedOutputStreamBuffered output stream
ByteArrayOutputStreamOutput stream that writes to a byte array
DataOutputStreamAn output stream that contains methods for writing the Java standard data types
FileOutputStreamOutput stream that writes to a file
FilterOutputStreamImplements OutputStream
ObjectOutputStreamOutput stream for objects
PipedOutputStreamOutput pipe

Next chapter...

What you will learn in the next chapter:

  1. How to use FileOutputStream
  2. Create FileOutputStream object from File object
  3. Append output to file using FileOutputStream
  4. How to copy a file with FileInputStream and FileOutputStream
  5. Write byte array to a file using FileOutputStream
Home » Java Tutorial » Reader Writer
Stream vs Reader and writer
InputStream
FileInputStream
ObjectInputStream
DataInputStream
BufferedInputStream
SequenceInputStream
PushbackInputStream
ByteArrayInputStream
PrintStream
OutputStream
FileOutputStream
DataOutputStream
ObjectOutputStream
BufferedOutputStream
ByteArrayOutputStream
FilterOutputStream
Reader
FileReader
BufferedReader
CharArrayReader
StringReader
LineNumberReader
InputStreamReader
PushbackReader
Writer
FileWriter
BufferedWriter
CharArrayWriter
StringWriter
PrintWriter
OutputStreamWriter