PathFragment[] (String head, String special, String tail) { ArrayList<PathFragment> list = new ArrayList<>(3); if (head != null) { if (special != null || tail != null) list.add(new PathFragment(head + File.separatorChar, true)); else return new PathFragment[]{new PathFragment(head, true)}; } if (special != null) { if (tail != null) list.add(new PathFragment(special + File.separatorChar, false)); else list.add(new PathFragment(special, false)); } if (tail != null) list.add(new PathFragment(tail, true)); return list.toArray(new PathFragment[0]); }