DataInputStream Readlong() Example
Returns the next eight bytes of this input stream, interpreted as a long.
DataInputStreamclass Readlong() method example. This example shows you how to use Readlong() method.This method Returns the next eight bytes of this input stream, interpreted as a long.
Here is the code:-
/**
* @Program that Returns the next eight bytes of this input stream, interpreted
as a long.
* Readlong.java
* Author:-RoseIndia Team
* Date:-07-jun-2008
*/
import java.io.*;
public class Readlong {
public static void main(String[] args)throws IOException {
long lL = 23;
FileOutputStream fos = new FileOutputStream("Linux.txt");
DataOutputStream dos = new DataOutputStream(fos);
dos.writeLong(lL);
dos.flush();
dos.close();
FileInputStream fis = new FileInputStream("Linux.txt");
DataInputStream dis = new DataInputStream(fis);
long l = dis.readLong();
System.out.println("The next eight bytes of this input stream is :" + l);
}
} |
Output of the Program
| The next eight bytes of this input stream is :23 |
|