Mourning the loss of our friend, WhitPhil.
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
 
Software Development
Tag Cloud
access audio black screen blue screen boot bsod connection crash dell desktop driver drivers dvd email error excel excel 2003 firefox hard drive hardware hdmi internet keyboard laptop malware monitor motherboard network networking outlook problem recovery router screen slow sound spyware tdlwsp.dll trojan upgrade vba video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Software Development >
java Scanner help

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

 
Thread Tools
spicyB's Avatar
Junior Member with 3 posts.
 
Join Date: Nov 2009
06-Nov-2009, 01:04 PM #1
java Scanner help
I am trying to use the Scanner to read input from the command line. I am unfamilier with the Scanner. How would I get something like "Scanner help" to be read as one single token?
spicyB's Avatar
Junior Member with 3 posts.
 
Join Date: Nov 2009
06-Nov-2009, 01:05 PM #2
thanks
JimmySeal's Avatar
Senior Member with 206 posts.
 
Join Date: Sep 2007
Experience: Getting there
07-Nov-2009, 06:45 PM #3
I don't really understand the question. If the input were "Scanner help is good", how would you identify "Scanner help" as one token and "is" and "good" as individual tokens?
spicyB's Avatar
Junior Member with 3 posts.
 
Join Date: Nov 2009
09-Nov-2009, 02:52 AM #4
The user would enter input like "Scanner help" "is" "good"
and then "Scanner help", "is", "good" would all be different tokens. THe user would enter their input with the " " around each different token
JimmySeal's Avatar
Senior Member with 206 posts.
 
Join Date: Sep 2007
Experience: Getting there
09-Nov-2009, 09:39 PM #5
When you say you want to get input from the command line, are you referring to the command line arguments, or input the program will read from the user while the program is running?
If it's the former, then the command line automatically divides up arguments based on quotation marks. So if I have this program:

Code:
public class test
{
        public static void main(String[] args)
        {
                for(int i = 0; i < args.length; i++)
                {
                        System.out.println(args[i]);
                }
        }
}
And then run
java test "hello dolly" "yoyo" "waawa"
Then the output will be
hello dolly
yoyo
waawa
Reply Bookmark and Share

Smart Search

Find your solution!



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.

Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 04:54 PM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.