Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-31-2007, 04:52 AM
Member
 
Join Date: Jul 2007
Posts: 40
Rep Power: 0
baltimore is on a distinguished road
Default Help with a word, if it is divided by spaces
Hi, I am having a problem with this java program i am making. So far it is suppose to just get a command and break it down into a list where each part is a word so it is divided by spaces. But i am having problems so far this is what i have.

Code:
 import java.io.*;
 
 public class Command
 {
 	private static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
 	private static String uR,con,sub1;
 	private static[] String test;
 	private static int a,b;
 	
 	public static void main(String[] args)
 	throws Exception
 	{
 		while(true)
 		{
 			b= -1;
	 		File data = new File("C:/");
	 		System.out.print(data+">");
	 		uR = in.readLine();
	 		System.out.println(uR);
	 		if(uR.equals("exit"))
	 		{
	 			System.exit(0);
	 		}
	 	}
 	}
 }
All i have to figure out is how to break uR up and into test. Any help?
Thanks.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 08-07-2007, 07:31 AM
Member
 
Join Date: Jul 2007
Posts: 40
Rep Power: 0
mathias is on a distinguished road
Default
A friend of mine points out you could just use .split(" ") on the string. Alternatively, .split("\\s+") might be better if there are several spaces or tab characters you would like to split on.
Greetings.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Load URL that contains spaces? barkster Java Applets 0 01-30-2008 10:40 PM
Word Scramble lk9865 New To Java 5 11-17-2007 03:22 AM
Reading file data that contains no spaces jdepue Advanced Java 1 08-01-2007 05:58 AM
How to update Existing Word Doc Using java umashankar Advanced Java 1 07-27-2007 02:29 PM
How to know the exact word on which the mouse is, in a JTextArea JavaBean AWT / Swing 1 05-19-2007 01:03 PM


All times are GMT +2. The time now is 07:39 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org