1

There seems to be a large number of non-consistent conventions referring to parts of a filename based on platform, programming language, etc. PHP uses one terminology, POSIX something else, etc. Is there an accepted standard in Java?

For example, given filename: c:\dev\project\file.txt, Apache Commons FilenameUtils defines the following:

c:\dev\project\file.txt

  • the prefix - C:\
  • the path - dev\project\
  • the full path - C:\dev\project\
  • the name - file.txt
  • the base name - file
  • the extension - txt

However, this class leaves out the nomenclature used to refer to the complete string (ie: c:\dev\project\file.txt). It already uses "path" to refer to the folder structure, so that cannot be reused.

What is the proper term I can use to refer to the entire c:\dev\project\file.txt? A reference to an authoritative source defining the term would be appreciated as well.

Furthermore, how would you treat an instance where you have a file called: c:\dev\project\file.txt.ext2.ext3? Would basename now be file.txt.ext2? Is extension, by definition, the part of the filename which trails the last '.'? I suspect that the complete filename should be basename + extension?

Eric B.
  • 23,425
  • 50
  • 169
  • 316
  • @Trobbins - I have edited the question to rephrase that section to ask if there is an authoritative source. If that is really the source of the downvotes and the close requests. – Eric B. Sep 03 '15 at 16:20
  • @Solver - I am not sure either; I specifically formulated the question to not be an open ended question, but apparently others feel that it is still not valid - I would love to know why. It isn't a duplicate of something on SO either, as it is specifically geared towards Java nomenclature. – Eric B. Sep 03 '15 at 16:21
  • I nominating this question for reopening. My opinion, I would call the entire string the "file path". – nickb Sep 03 '15 at 16:52
  • 1
    Not authoritative, but I would call it an "absolute file name". – Henry Sep 03 '15 at 17:15
  • I also vote to reopen. But as for your question I think the file name is not for any language specification it is for the OS to define what it is and how it is defined or identified. See this article on Wiki about file there are good relevant information: [Computer File](https://en.wikipedia.org/wiki/Computer_file) and this one about the [filename extension](https://en.wikipedia.org/wiki/Filename_extension) – Jorge Campos Sep 03 '15 at 17:20
  • 2
    As stated by the [javadoc](http://commons.apache.org/proper/commons-io/apidocs/org/apache/commons/io/FilenameUtils.html): "This class defines six components within a filename (example C:\dev\project\file.txt):" so "filename" –  Sep 03 '15 at 17:21
  • Why would you use Apache Commons as your source? What about java.nio.file.Path? The path should not be just the directories to the file but no including the file. – matt Sep 03 '15 at 17:30
  • @RC The excerpt from the javadoc is already in my question. I'm specifically asking about the parts that it does not answer. – Eric B. Sep 03 '15 at 18:27
  • @matt I was unable to find anything in the core java docs, and Apache Commons (pretty common libraries to use) were clear and well documented. I also surmised that the developers for an Open Source project (like Commons) were able to agree on a nomenclature, so I based myself on that source. However, like I alluded to, there are cases which are not clear. – Eric B. Sep 03 '15 at 18:28
  • @Eric B. I don't want to go through and paste the relevant sections from the [Path](http://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html) javadocs but the path is what you are asking for. This is the same in most os's. The file name is the name of the file. So in your example, the path could be, `c:\dev\project\file.txt` or `project\file.txt` or `file.txt`. depending on if it is relative or absolute. – matt Sep 03 '15 at 20:21

0 Answers0