What does abstract path means in java.io?

后端 未结 3 1102
你的背包
你的背包 2021-02-06 01:12

In java doc about

File#getPath()

writes:

 Converts this abstract pathname into a pathname string.

I try to w

相关标签:
3条回答
  • 2021-02-06 01:53

    An abstract pathname is a java.io.File object and a pathname string is a java.lang.String object. Both reference the same file on the disk.

    How do I know?

    The first sentence of the Javadoc of java.io.File explains:

    An abstract representation of file and directory pathnames.

    It goes on to explain why:

    User interfaces and operating systems use system-dependent pathname strings to name files and directories. This class presents an abstract, system-independent view of hierarchical pathnames.

    0 讨论(0)
  • 2021-02-06 02:00

    The abstract pathname is just the string form of the file/location held in the File object.

    If you check the javadoc of File#toString():

    Returns the pathname string of this abstract pathname. This is just the string returned by the getPath() method.

    0 讨论(0)
  • 2021-02-06 02:00

    See javadoc: abstract pathname = File

    1. An optional system-dependent prefix string, such as a disk-drive specifier, "/" for the UNIX root directory, or "\\" for a Microsoft Windows UNC pathname, and
    2. A sequence of zero or more string names. [refering to directories and file

    These are independent of operating system peculiarities of notation.

    The string form gives you what you need to write on your current operating system to refer to that file.

    0 讨论(0)
提交回复
热议问题