All About Class OutputStream in Java

0
40
Spread the love
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share

Class OutputStream in Java
Class OutputStream in Java

Class OutputStream in Java:

OutputStream class is an abstract super class of all classes that represent an output stream of bytes.An application that need to define a subclass of OutputStream must always provide at least a method that writes one byte of output.

The classes and subclasses of Class OutputStream are:

Class Sub class Further Subclass
OutputStream PipedOutputStream
FilterOutputtStream DataOutputStream
BufferedOutputStream
PrintStream
ByteArrayOutputStream
FileOutputStream

The class structure of OutputStream is given as:


public abstract class java.io.OutputStream extends java.lang.Object{
//constructor
public OutputStream();
//default constructor
//methods:
public void close();//closes the input source;further read attempt on a closed input will generate
//an IOException.
public void flush();//flush the file buffer
public void write(byte b[]);//writes an entire byte array i.e block of bytes at a time.
public void write(byte b[],int offSet,int length);//write out length number of bytes from the block of 
//bytes b starting at offset offSet.
public abstract void write(int b);//writes one byte at a time
}
 

In addition,all methods may throw an IOException if an IO error occurs apart from their regular Exceptions.

Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share

LEAVE A REPLY

Please enter your comment!
Please enter your name here