-3
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.

Fred Larson
  • 60,987
  • 18
  • 112
  • 174

1 Answers1

1

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.

Vishwa Ratna
  • 5,567
  • 5
  • 33
  • 55
Andry Shutka
  • 283
  • 1
  • 4