Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Pro Java
|
Pro Java Expert level Java questions not about a specific book. Please indicate your version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro Java section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 9th, 2007, 09:45 AM
Registered User
 
Join Date: May 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default using delimiters---i need Heeeeelp!!!

i need to enter commands in one line using delimiter "&" (ampersand) or ";" (semicolon),using one type of delimiter in a line. e.g "cat&cp&rm" or "cat;cp;rm". Both should not be used in one line e.g "cat;cp&rm", when this happens the system exits.
I've tried the code below using Split method but i want to use an IF statement for the above condition. i also want to run a thread for each command if the commands are seperated by "&" and run only one thread for all commands being executed one after another if they're seperated by ";".

Code:
import java.lang.*;
import java.io.*;
import java.util.*;

public class Parsing
{
     public static void main(String args[]) throws Exception
     {
          new Parsing().Split();
     }

     public void Split()
    {
         String command = " ";
     System.out.print("Enter command: " );
     try{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        command = br.readLine();

              String [] temp = null;
              temp = command.split("\\&");

            /*if((temp.equals("&")) || (temp.equals(";")))
            {
           write(temp);
            }
               else
           {
          System.exit(0);
           }*/

      }catch (IOException e){}
    }

  public void write(String []s)
  {
      for (int i = 0 ; i < s.length ; i++)
      {
          System.out.println(s[i]);
      }

  }
}

how should i do that? please help me. even if there's no actual solution, i need your suggestions. Thanks in advance
 
Old June 15th, 2007, 06:55 AM
Friend of Wrox
 
Join Date: Dec 2003
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts
Default

http://p2p.wrox.com/topic.asp?TOPIC_ID=61626

--
Charlie Harvey's website - linux, perl, java, anarchism and punk rock: http://charlieharvey.org.uk





Similar Threads
Thread Thread Starter Forum Replies Last Post
using delimiters---i need Heeeeelp!!! ssimkhan Java Basics 1 June 15th, 2007 06:22 AM
how to read delimiters debo_sbg XSLT 7 May 11th, 2005 11:20 AM
Export Delimiters CodingMonkey VB Databases Basics 0 August 19th, 2004 12:40 PM
dbgrid export and print...HEEEEELP!!!! killer_kamatis VB How-To 0 August 9th, 2003 11:15 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.