Find first element in a string Split by char - Android java.lang

Android examples for java.lang:String Split

Description

Find first element in a string Split by char

Demo Code

import java.io.UnsupportedEncodingException;
import java.util.*;

public class Main{

    /**// www .  j a  va 2  s.c o  m
     * Find first element, Split by char
     *
     * @param src string to be split
     * @param ch  which is used to split <code>src</code>
     * @return string after split with first char
     */
    public static String splitFirst(String src, char ch) {
        return src.substring(0, src.indexOf(ch));
    }

}

Related Tutorials