Java - Write code to convert string to List by using three splitor

Requirements

Write code to convert string to List by using three splitor

Demo

//package com.book2s;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {
    public static void main(String[] argv) {
        String str = "bo|o|k2{s]}.com";
        System.out.println(toList(str));
    }/* w  w  w  .ja v  a 2 s  . c  o  m*/

    public static List<String> toList(String str) {
        if (str == null) {
            return new ArrayList<String>();
        }
        return Arrays.asList(str.split("[,?| ]"));
    }
}

Related Exercise