DataOutputStream Write2() Example

Writes len bytes from the specified byte array starting at offset off to the underlying output stream.


DataOutputStreamclass Write2() method example. This example shows you how to use Write2() method.This method Writes len bytes from the specified byte array starting at offset off to the underlying output stream.

Here is the code:-

/**
 * @Program that Writes len bytes from the specified byte array starting at 
 * offset off to the underlying output stream.. 
 * Write2.java 
 * Author:-RoseIndia Team
 * Date:-09-jun-2008
 */
import java.io.*;
public class Write2 {
public static void main(String[] argsthrows IOException{
byte[]b={1,2,3,4,5};
FileOutputStream fos=new FileOutputStream("g.txt");    
DataOutputStream dos=new DataOutputStream(fos);
//Writes len bytes from the specified byte array starting at offset
dos.write(b,0,b.length-2);
FileInputStream fis=new FileInputStream("g.txt");    
DataInputStream dis=new DataInputStream(fis);
System.out.println("Bytes to be written out to the stream. "+dis.read(b));
    }
}

Output of the Program
 Bytes to be written out to the stream. 3

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US