![]() JavaProject is the current user directory. It is interpreted through information taken from some other pathname.įor example, JavaProject\src\JavaProgram\ScienceDemo.java is a relative pathname. Relative Pathname in JavaĪ relative pathname is a pathname that does not start with the root directory symbol. No other information is required to locate this file in the system. This complete name is the absolute pathname of the file ScienceDemo.java. Complete means no other information is required to locate a file.įor example, suppose the file ScienceDemo.java is placed at the following location: C:\Java\workspace\JavaProject\src\JavaProgram\ScienceDemo.java ![]() Absolute Pathname in JavaĪn absolute pathname is a pathname that starts with a root directory symbol. When an abstract pathname is converted into a pathname string, each name is separated from the next name by the default name separator character.įor example, File(String pathname) converts pathname string /Java/myfile.dat to abstract pathname \Java\myfile.dat on a Windows platform and /Java/myfile.dat on the Linux platform. The last name in the abstract pathname represents a file or directory. When a file or directory is stored in a system, the pathname string that represents the name is machine-dependent.Īn abstract pathname consists of an optional prefix string, such as disk drive specifiers, “/” for Unix, or “\\” for Windows, and a sequence of zero or more string names. In the second statement, a pathname starts with drive specifier D:, and continues with root directory symbol \, directory name Java, separator character \, and filename myfile.dat. In the first statement, a pathname starts with the root directory symbol /, and continues with directory name Java, separator character /, file name myfile.dat. The statements are: 1) File file = new File("/Java/myfile.dat") // For Unix or Linux platform.Ģ) File file = new File("D:\\Java\\myfile.dat") // For Windows platform. A separator character (such as Windows backslash ) that is platform-dependent is present between the consecutive names.įor example, suppose we create two objects of the File class that stores two pathname strings. A pathname is a string representation of a path.
0 Comments
Leave a Reply. |