There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Software Development
Tag Cloud
access acer asus bios bsod computer crash desktop driver drivers error ethernet excel freeze gaming hard drive hardware hdmi internet laptop malware memory modem monitor motherboard netgear network printer problem ram registry repair router slow software sound toshiba trojan usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless xbox
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Software Development >
java Scanner help

Reply  
Thread Tools
spicyB's Avatar
Junior Member with 3 posts.
 
Join Date: Nov 2009
06-Nov-2009, 02: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, 02:05 PM #2
thanks
JimmySeal's Avatar
Computer Specs
Member with 289 posts.
 
Join Date: Sep 2007
Experience: Getting there
07-Nov-2009, 07: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, 03: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
Computer Specs
Member with 289 posts.
 
Join Date: Sep 2007
Experience: Getting there
09-Nov-2009, 10: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

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




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



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 11:19 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.