So what I need to do in this program is go through a file and check for symbols/labels, then im storing those labels in an array for later access. then go through again and convert the instructions.
now after i go through the file once, i want to go through it again, starting from the top, but im not sure how this is done.
i tried this:
Scanner sc = new Scanner(new File("asm.asm")); Scanner sc2 = new Scanner(new File("asm.asm"));
Assuming that each one would point to the beginning of the file, so i could go through using sc then when im done go through and use sc2 which would still be at the beginning of the file since its a different scanner.
but i get an error when it gets to the 2nd scanner:
while(sc2.hasNextLine()) { //error happens on this line, no such element exception input = sc.nextLine(); }
So i'm wondering am I going about this the wrong way or am I just not executing my idea properly? If there is an easier way to do this please let me know (like maybe there is a command to reset the scanner to the beginning of the file that i dont know about). Thank you for the help.