Convert a space-separated string into an array of strings. - Java Collection Framework

Java examples for Collection Framework:Array Convert

Description

Convert a space-separated string into an array of strings.

Demo Code


//package com.java2s;

public class Main {


    /** //from  w  ww .  j  a  v  a  2s .  c  o  m
     * Convert a space-separated string into an array of strings.
     * 
     * @param msg String separated by spaces
     * @return String array of tokens in string.
     */
    public static String[] GetTokens(String msg) {
        return msg.split("\\s+");
    }
}

Related Tutorials