Java tutorial
//package com.java2s; import android.support.annotation.NonNull; import java.util.ArrayList; public class Main { /** * Parse path into an ArrayList using the '/' path separator. * * @param path the string to be split into the ArrayList * @return the array of path segments */ public static ArrayList<String> parsePath(String path) { return nonblankPathSegments(path.split("/")); } @NonNull private static ArrayList<String> nonblankPathSegments(Object[] paths) { ArrayList<String> list = new ArrayList<>(); for (Object path : paths) { if (path != null && !path.equals("")) { list.add((String) path); } } return list; } }