code: public static List<String> getPathComponents(File file)
    {
      if(file == null) {
        return Collections.emptyList();
      }
      List<String> pathComponents = new ArrayList<String>();
      do {
        pathComponents.add(0, file.getName());
        file = file.getParentFile();
      }
      while(file != null);
      return pathComponents;
    }
docs: Get file path components. Return a list of path components in their natural order. List first item is path root
  stored as an empty string; if file argument is empty returned list contains only root. If file argument is null
  returns empty list.
  
  @param file file to retrieve path components.
  @return file path components.