-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBinFileRead.java
More file actions
32 lines (27 loc) · 708 Bytes
/
BinFileRead.java
File metadata and controls
32 lines (27 loc) · 708 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package java_Files;
import java.io.*;
public class BinFileRead {
public static void main(String[] args) {
// TODO Auto-generated method stub
readFile();
}
private static void readFile() {
// TODO Auto-generated method stub
// try-resource Óï¾ä£¬×Ô¶¯ÊÍ·ÅÁ÷
try (DataInputStream dis = new DataInputStream(
new BufferedInputStream(new FileInputStream("c:/temp/def.dat")))) {
String a, b;
int c, d;
a = dis.readUTF();
c = dis.readInt();
d = dis.readInt();
b = dis.readUTF();
System.out.println("a: " + a);
System.out.println("c: " + c);
System.out.println("d: " + d);
System.out.println("b: " + b);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}