Happy for suggestions here. Originally I had planned on using java.net.URI(uri) but it didn't have a method to get the "file". Then I thought about using URL but "hdfs" is not a valid protocol for URL (and URI.toURL doesn't work either).

I'm not sure what we did before ... we might have done the extracting ourselves so we didn't need to determine the directory here.