Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 25-11-2008
Member
 
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!
Reply With Quote
  #2  
Old 25-11-2008
Member
 
Join Date: Jan 2008
Posts: 1,515
Re: Scanner problems (java)

Code:
Scanner sc = new Scanner (System.in); 
String = into sc.nextLine (); 
if (in.equals ("")) 
   System.exit (0);
Reply With Quote
  #3  
Old 25-11-2008
Member
 
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?
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags:



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Scanner problems (java)"
Thread Thread Starter Forum Replies Last Post
Java barcode scanner Rily Software Development 6 28-07-2010 10:33 AM
Scanner & PrintStream Issue in Java visioneye Software Development 3 21-07-2010 05:56 AM
How to add parse in scanner in java? MAGAR Software Development 5 02-03-2010 04:30 PM
Scanner can't read in java cyber-noob Software Development 3 14-11-2009 12:42 PM
Problems with HP PSC 750 scanner ameer123 Hardware Peripherals 2 07-10-2008 02:29 PM


All times are GMT +5.5. The time now is 12:16 AM.