Results 1 to 3 of 3

Thread: Scanner problems (java)

  1. #1
    Join Date
    Oct 2008
    Posts
    31

    Scanner problems (java)

    my problem is the following:

    The program will run until the user press "Enter" but indicated nothing.

    I thought something like this:

    Code:
    Scanner sc = new Scanner (System.in); 
    
    String = into sc.next (); 
    
    if (in == null) 
    System.exit (0);
    but because the scanner does not accept empty tokens it does not work so!
    (enter enter-pressure leads to a new line in the terminal window, but in the program hands "no".)

    If anyone has any solution to my problem, I would be very grateful!

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Scanner problems (java)

    Code:
    Scanner sc = new Scanner (System.in); 
    String = into sc.nextLine (); 
    if (in.equals ("")) 
       System.exit (0);

  3. #3
    Join Date
    Oct 2008
    Posts
    31

    Re: Scanner problems (java)

    Code:
      Scanner scanner input = new Scanner (System.in); 
      while ((String input = scannerInput.nextLine ())! = "") ( 
      )
    Do I mean it right?

Similar Threads

  1. Java barcode scanner
    By Rily in forum Software Development
    Replies: 6
    Last Post: 28-07-2010, 10:33 AM
  2. Scanner & PrintStream Issue in Java
    By visioneye in forum Software Development
    Replies: 3
    Last Post: 21-07-2010, 05:56 AM
  3. How to add parse in scanner in java?
    By MAGAR in forum Software Development
    Replies: 5
    Last Post: 02-03-2010, 04:30 PM
  4. Scanner can't read in java
    By cyber-noob in forum Software Development
    Replies: 3
    Last Post: 14-11-2009, 12:42 PM
  5. Problems with HP PSC 750 scanner
    By ameer123 in forum Hardware Peripherals
    Replies: 2
    Last Post: 07-10-2008, 02:29 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,042,882.09927 seconds with 16 queries