How to make a new scanner read all the console in a command line interface
I am building a command line interface, for a very primitive spreadsheet application.
In my application I would like to add a saving feature, where when I write save and then followed by the file name
in the command line. I transfer all of my previous text from the command line to a file.
In order to do that I have to somehow create a new scanner that starts from the beginning om my text commands,
and then read them in line by line, and then when it reaches the save keyword it stops.
So how would you do this?
I have this command interpreter class, which has got an interpret method, which has got a scanner as its input. This scanner like moves with every command issues, and thereby cannot read in all the stuff from the top of the console.
Re: How to make a new scanner read all the console in a command line interface
Scanner uses System.in, which listens for user input.
It doesn't store anything, it only passes on input as it gets it.
You'll either need to store all the previous stuff or use some sort of ncurses library (JCurses maybe?).