Java tutorial
//package com.java2s; public class Main { /** * Split string to array of path array. * @param path "/root/elementA/elementB" * @return */ public static String[] toPathArray(String path) { if (path.charAt(0) == '/') path = path.substring(1); return path.split("/"); } }