Java String Divide divide(final String s)

Here you can find the source of divide(final String s)

Description

When using commands you seperate the command from the arguments with a space.

License

Open Source License

Parameter

Parameter Description
s String to divide

Return

Array made with command and arguments

Declaration

public static String[] divide(final String s) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*w  ww . java 2s  . c  o  m*/
     * When using commands you seperate the command from the arguments with a
     * space. divide gets a command and returns the command and the args in an
     * Array.
     * 
     * @param s
     *            String to divide
     * @return Array made with command and arguments
     */
    public static String[] divide(final String s) {
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == ' ') {
                final String[] res = { s.substring(0, i).trim().toLowerCase(),
                        s.substring(i, s.length()).trim().toLowerCase() };
                return res;
            }
        }
        final String[] res = { s.trim().toLowerCase(), "" };
        return res;
    }
}

Related

  1. div(String content, String extra)
  2. div(String second, String first)
  3. div(String text)
  4. divide(Object o1, Object o2, String type)
  5. divide(String m)
  6. divide(String str, char c)
  7. divide(String ts, String ms)