public static String[] parse(String cmdline) {
      if(cmdline == null) {
         return new String[0];
      }
      
      char[] chars = cmdline.toCharArray();
      
      boolean inquote = false;
      
      ArrayList args = new ArrayList();
      StringBuffer buf = new StringBuffer();
      for(int i=0;i<chars.length;i++) {
         char c = chars[i];
         //quote
         if(c == '\"') {
            if(!inquote) {
               inquote = true;
               continue;
            }
            else {
               args.add(buf.toString());
               buf = new StringBuffer();
               inquote = false;
               continue;
            }
         }
         
         //space
         if(c == ' ' && !inquote) {
            if(buf.length()==0)
               continue;
            else {
               args.add(buf.toString());
               buf = new StringBuffer();
               continue;
            }
         }
         
         //append the char
         buf.append(c);
      }
      
      //append last arg
      if(buf.length()!=0) {
         args.add(buf.toString());
      }
      
      return (String[])args.toArray(new String[args.size()]);
   }