-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathu2.java
More file actions
42 lines (40 loc) · 923 Bytes
/
u2.java
File metadata and controls
42 lines (40 loc) · 923 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 u2 {
public int d;//data
public u2(byte[] b) {
this.d = 0;
for (int i = 0; i < 2; i++) {
int t = b[i];
t = (t < 0) ? 256 + t : t;
this.d *= 256;
this.d += t;
}
}
public u2(FileInputStream fis) throws IOException {
byte[] b2 = new byte[2];
fis.read(b2);
this.setu2(b2);
}
public void setu2(byte[] b) {
this.d = 0;
for (int i = 0; i < 2; i++) {
int t = b[i];
t = (t < 0) ? 256 + t : t;
this.d *= 256;
this.d += t;
}
}
public String toString() {
String allHex = "0123456789abcdef";
Vector<String> hex = new Vector<String>();
int actuel = this.d;
for (int i = 0; i < 4; i++) {
hex.add(0, ""+ allHex.charAt(actuel%16));
actuel /= 16;
}
return String.join("", hex.toArray(new String[0]));
}
}