-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathu4.java
More file actions
42 lines (40 loc) · 935 Bytes
/
u4.java
File metadata and controls
42 lines (40 loc) · 935 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
33
34
35
36
37
38
39
40
41
42
package javaDisassembly;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Vector;
public class u4 {
public long d;// data
public u4(byte[] b) {
this.d = 0;
for (int i = 0; i < 4; i++) {
long t = b[i];
t = (t < 0) ? 256 + t : t;
this.d *= 256;
this.d += t;
}
}
public void setu4(byte[] b){
this.d = 0;
for (int i = 0; i < 4; i++) {
long t = b[i];
t = (t < 0) ? 256 + t : t;
this.d *= 256;
this.d += t;
}
}
public u4 (FileInputStream fis) throws IOException {
byte[] b4 = new byte[4];
fis.read(b4);
this.setu4(b4);
}
public String toString() {
String allHex = "0123456789abcdef";
Vector<String> hex = new Vector<String>();
long actuel = this.d;
for (int i = 0; i < 8; i++) {
hex.add(0, ""+ allHex.charAt((int)(actuel%16)));
actuel /= 16;
}
return String.join("", hex.toArray(new String[0]));
}
}