0 START
1 LOAD 20
2 STORE 200
3 LOAD 0
4 STORE 201
5 STORE 202
6 CMPM 200
7 CJMP 15
8 LOADM 202
9 ADDM 201
10 STORE 202
11 LOADM 201
12 ADD 1
13 STORE 201
14 JMP 6
15 LOADM 202
16 DISP
17 HALT
I want to split this file by instructions and values like String = "LOAD" int = 20 and remove line numbers.
you need to read this file line by line as described for example here How can I read a large text file line by line using Java?
then for each line you need to do smth. like
String[] split = line.split("\\s+");
in split array you will have your values for example {"2", "STORE", "200"}
just parse or perform Integer.valueOf()
for those that are actually numbers.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.