Java Array Create toArray(String str, String split)

Here you can find the source of toArray(String str, String split)

Description

to Array

License

Open Source License

Declaration

public static String[] toArray(String str, String split) 

Method Source Code

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

public class Main {
    public static String[] toArray(String str, String split) {
        if (isNull(str)) {
            return null;
        }//from  w  w w  .j ava  2  s  .c om
        if (isNull(split)) {
            split = ",";
        }
        return str.split(split);
    }

    public static boolean isNull(String str) {
        if (str == null)
            return true;
        if ("null".equalsIgnoreCase(str)) {
            return true;
        }
        if ("".equals(str))
            return true;
        return false;
    }

    public static boolean equalsIgnoreCase(String s1, String s2) {
        if (s1 == null) {
            if (s2 == null) {
                return true;
            } else {
                // return s2.equalsIgnoreCase(s1);
                return false;
            }
        } else {
            if (s2 == null) {
                return false;
            } else {
                return s1.equalsIgnoreCase(s2);
            }

        }
    }

    public static boolean equals(String s1, String s2) {
        if (s1 == null) {
            if (s2 == null) {
                return true;
            } else {
                // return s2.equals(s1);
                return false;
            }
        } else {
            return s1.equals(s2);
        }
    }
}

Related

  1. newArray(Object src, int len)
  2. newArray(String... args)
  3. toArray(String source, String delimiter)
  4. toArray(String str)
  5. toArray(String str)
  6. toArray(String string)
  7. toArray(String text)
  8. toArray(T... items)
  9. toArray(T... items)