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 ";".

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

You don't need to import java.lang. Its implicit.

As for your problem, use the function to find the index of both the characters '&' and ';'. If both are not equal to -1 means that both the characters are present and the command is invalid. If any one of them is present, handle it accordingly using the if blocks.