Android String Split splitDirString(String dirSection)

Here you can find the source of splitDirString(String dirSection)

Description

split Dir String

Declaration

public static String[] splitDirString(String dirSection) 

Method Source Code

//package com.java2s;

public class Main {

    public static String[] splitDirString(String dirSection) {
        if (dirSection == null || "".equals(dirSection.trim()))
            return null;
        dirSection = dirSection.trim();//  ww  w . ja  v a 2  s  .  co m
        if ('/' == (dirSection.charAt(0))) {
            dirSection = dirSection.substring(1);
        }
        if (dirSection != null && !"".equals(dirSection)) {
            if ('/' == (dirSection.charAt(dirSection.length() - 1))) {
                dirSection = dirSection.substring(0,
                        dirSection.length() - 1);
            }
        }
        if (dirSection != null && !"".equals(dirSection)) {
            String[] dirs = dirSection.split("/");
            return dirs;
        }
        return null;
    }
}

Related

  1. split(String str, String delim)
  2. split(String str, String delimiter)
  3. split(String str, String delims)
  4. split(String str, String separator)
  5. split(final String str, final String delim)
  6. splitInts(String str)
  7. splitLast(String target, String pattern)
  8. splitSteps(String str, String split)
  9. splitString(String tokenedStr, String token)