DataInputStream ReadFully1() Example
Bytes for this operation are read from the contained inputstream.
DataInputStreamclass ReadFully1() method example. This example shows you how to use ReadFully1() method.This method gives the way of how Bytes for this operation are read from the contained inputstream.
Here is the code:-
/**
* @Program in which Bytes for this operation are read from the contained input
stream.
* ReadFully1.java
* Author:-RoseIndia Team
* Date:-07-jun-2008
*/
import java.io.*;
public class ReadFully1 {
public static void main(String[] args)throws IOException {
byte[] bB = {1, 2, 3, 4, 5, 6, 7};
FileOutputStream fos = new FileOutputStream("Linux.txt");
DataOutputStream dos = new DataOutputStream(fos);
dos.write(bB);
dos.flush();
dos.close();
FileInputStream fis = new FileInputStream("Linux.txt");
DataInputStream dis = new DataInputStream(fis);
dis.readFully(bB, 1, bB.length-2);
for (int i = 3; i < bB.length; i++) {
System.out.println(bB[i]);
}
}
}
|
|