Class OutputStream

OutputStream is an interface for stram-based objects for writing bytes.

Methods


close

Closes the OutputStream. Closed stream cannot be used for writing.

Example

main
  // FileWriter is used in this example, as it implements OutputStream
  FileWriter fw = new FileWriter "file.dat"
  fw.close
                

(bool) is open

Checks if the OutputStream is open.

Return value

Example

main
  // FileWriter is used in this example, as it implements OutputStream
  FileWriter fw = new FileWriter "file.dat"
  bool isOpen = fw.is open                  // isOpen == true
  fw.close
                

write <byte[] data>

Writes a byte[] to a OutputStream.

Parameters

Exceptions

Example

main
  // FileWriter is used in this example, as it implements OutputStream
  FileWriter fw = new FileWriter "file.dat"
  // Assume byteArray will be initialised to random data.
  Byte[] byteArray
  fw.write byteArray
  fw.close
                

write range <range dataRange> of <byte[] data>

Writes a defined sub-range of a byte[].

Parameters

Exceptions

Example

main
  // FileWriter is used in this example, as it implements OutputStream
  FileWriter fw = new FileWriter "file.dat"
  // Assume byteArray will be initialised to 2000 bytes of random data
  Byte[] byteArray
  // Write first 1000 bytes.
  fw.write range 0 size 1000 of byteArray
  fw.close