Results 1 to 2 of 2
  1. #1
    baltimore is offline Member
    Join Date
    Jul 2007
    Posts
    40
    Rep Power
    0

    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.

    Java 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.

  2. #2
    mathias is offline Member
    Join Date
    Jul 2007
    Posts
    40
    Rep Power
    0

    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.

Similar Threads

  1. Load URL that contains spaces?
    By barkster in forum Java Applets
    Replies: 0
    Last Post: 01-30-2008, 09:40 PM
  2. Word Scramble
    By lk9865 in forum New To Java
    Replies: 5
    Last Post: 11-17-2007, 02:22 AM
  3. Reading file data that contains no spaces
    By jdepue in forum Advanced Java
    Replies: 1
    Last Post: 08-01-2007, 04:58 AM
  4. How to update Existing Word Doc Using java
    By umashankar in forum Advanced Java
    Replies: 1
    Last Post: 07-27-2007, 01:29 PM
  5. Replies: 1
    Last Post: 05-19-2007, 12:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •