Results 1 to 2 of 2
  1. #1
    lo2 is offline Member
    Join Date
    Nov 2012
    Rep Power

    Default How to make a new scanner read all the console in a command line interface

    Hi there

    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.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power

    Default Re: How to make a new scanner read all the console in a command line interface

    Scanner uses, 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?).
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 4
    Last Post: 10-26-2011, 02:24 AM
  2. Replies: 16
    Last Post: 09-17-2011, 02:41 AM
  3. How to make Scanner read the same line
    By mcollins in forum New To Java
    Replies: 2
    Last Post: 03-03-2009, 06:41 AM
  4. Reading a line from console using Scanner class
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-18-2008, 11:52 AM
  5. Read from console (Scanner Class)
    By hey in forum New To Java
    Replies: 10
    Last Post: 12-11-2007, 10:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts