Java String Split by Delimiter split(String s, String delimiter)

Here you can find the source of split(String s, String delimiter)

Description

split

License

Open Source License

Declaration

public static String[] split(String s, String delimiter) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2014,2015 Hideki Yatomi
 * All rights reserved. This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License v1.0 which
 * accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 ******************************************************************************/

import java.util.*;

public class Main {
    public static String[] split(String s, String delimiter) {
        StringTokenizer tk = new StringTokenizer(s, delimiter);
        List<String> list = new ArrayList<>();
        while (tk.hasMoreTokens()) {
            list.add(tk.nextToken());/*from w w  w  .j a v  a2 s. com*/
        }
        return list.toArray(new String[list.size()]);
    }
}

Related

  1. split(String s, String delim)
  2. split(String s, String delim)
  3. split(String s, String delim)
  4. split(String s, String delimiter)
  5. split(String s, String delimiter)
  6. split(String src, char delim)
  7. split(String src, char delim)
  8. split(String src, String delimiter)
  9. split(String str, char delim)