Java – Splitting a scanner string

javajava.util.scannersplit

import java.io.IOException;
import java.util.Scanner;


public class web_practice {

    /**
     * @param args
     * @throws IOException 
     */
    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub

        Scanner scanner = new Scanner(System.in);
        String input = scanner.next();

        int l = input.indexOf(' ');
        String cmd = input.substring(0, l);
        String end = input.substring(l);

        if (cmd.equals("define"));
        java.awt.Desktop.getDesktop().browse(java.net.URI.create("http://dictionary.reference.com/browse/" + end));
    }
}

I was trying to make a code to find the definition of a word by connecting it to dictionary.com and checking if they say the word "define" as the first word?

The splitting is not working.

Best Solution

public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub

        Scanner scanner = new Scanner(System.in);
        String input = scanner.next();

        int words[] = input.split(' ');

        if (words[0].equalsIgnoreCase("define")) {
            java.awt.Desktop.getDesktop().browse(java.net.URI.create("http://dictionary.reference.com/browse/" + words[0]));
        }
    }