Read a long from a file using DataInputStream in Java
Description
The following code shows how to read a long from a file using DataInputStream.
Example
/*from ww w .j a v a 2 s . co m*/
import java.io.DataInputStream;
import java.io.FileInputStream;
public class Main {
public static void main(String[] args) throws Exception {
FileInputStream fin = new FileInputStream("C:/Long.txt");
DataInputStream din = new DataInputStream(fin);
long l = din.readLong();
System.out.println("long : " + l);
din.close();
}
}