johndoe3344
Programmer
I'm trying to make a program which has a menu doing two things:
(1) Read data from an input file
(2) Write certain pieces of the most recently read data to an output file
(3) Exit
The user needs to be able to keep repeating choice 1 for as long as he/she wants, and then use choice 2 to write information to a text file. The user will keep coming back to the menu until he/she selects (3) Exit.
So I end up using code like String a = inFile.next; in option 1. And then in option 2, I try to do something like outFile.println(a); and it doesn't work because the variable's scope ends at where the curly brace ends for the conditional.
So is there a way that I can accomplish what I need to do?
(1) Read data from an input file
(2) Write certain pieces of the most recently read data to an output file
(3) Exit
The user needs to be able to keep repeating choice 1 for as long as he/she wants, and then use choice 2 to write information to a text file. The user will keep coming back to the menu until he/she selects (3) Exit.
So I end up using code like String a = inFile.next; in option 1. And then in option 2, I try to do something like outFile.println(a); and it doesn't work because the variable's scope ends at where the curly brace ends for the conditional.
So is there a way that I can accomplish what I need to do?