ArrayList<String> (File file) { ArrayList<String> result = new ArrayList<>(); File current = file; while (current != null) { result.add(getFileName(current)); current = current.getParentFile(); if (current != null) result.add(File.separator); } return result; }