All About Class DataOutputStream in Java

0
26
Spread the love
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share


DataOutputStream lets an application write primitive java data types to an output stream in a portable way.An application can then use a DataInputStream to read the data back.

The structure of class DataOutputStream is given as:


public class java.io.DataOutputStream extends java.io.FilterOutputStream implements java.io.DataOutput{
//Member element
protected int written;
//the number of bytes writes to the DataOutputStream
//constructor
public DataOutputStream(OutputStream out);
//Creates a new DataOutputStream to write data to the specified output stream
//methods:
public void flush();
public final int size();
public void write(byte b[],int offSet,int length);
public void write(int b);
public final void writeBoolean(boolean b);
public final void writeByte(int v);
public final void writeBytes(String str);
public final void writeChar(int v);
public final void writeChars(String s);
public final void writeDouble(double d);
public final void writeFloat(float f);
public final void writeInt(int v);
public final void writeLong(long l);
public final void writeShort(int i);
public final void writeUTF(string str);
 

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