public static List<String> splitPath(File file){
  List<String> output=new ArrayList<>();
  File current=file;
  while (current != null) {
    output.add(current.getName());
    current=current.getParentFile();
  }
  Collections.reverse(output);
  return output;
}

public static List < String > splitPath ( File file ) { List < String > output = new ArrayList < > ( ) ; File current = file ; while ( current != null ) { output . add ( current . getName ( ) ) ; current = current . getParentFile ( ) ; } Collections . reverse ( output ) ; return output ; }
split a file into a list of directories ending with the file name
