Java String Split split(String s)

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

Description

split

License

Open Source License

Declaration

public static String[] split(String s) 

Method Source Code


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

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static String[] split(String s) {
        List<String> result = new ArrayList<>();

        int counter = 0;

        while (counter <= s.length()) {
            int pos = s.indexOf(",", counter);

            if (pos == -1) {
                pos = s.length();//from w w w. j a v a  2 s  .co m
            }

            String fragment = s.substring(counter, pos);
            result.add(fragment.substring(1, fragment.length() - 1));

            counter += fragment.length() + 1;
        }

        return result.toArray(new String[result.size()]);
    }
}

Related

  1. split(String content)
  2. Split(String content, String sub_seq)
  3. split(String input)
  4. split(String input)
  5. split(String input)
  6. split(String s)
  7. split(String s)
  8. split(String s)
  9. split(String s)