0% found this document useful (0 votes)
3 views

File (Java Platform SE 7 )

Uploaded by

tarunsahani0000
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

File (Java Platform SE 7 )

Uploaded by

tarunsahani0000
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Java™ Platform

Overview Package Class Use Tree Deprecated Index Help Standard Ed. 7

Prev Class Next Class Frames No Frames All Classes


Summary: Nested | Field | Constr | Method Detail: Field | Constr | Method

java.io

Class File

java.lang.Object
java.io.File

All Implemented Interfaces:


Serializable, Comparable<File>

public class File


extends Object
implements Serializable, Comparable<File>

An abstract representation of file and directory pathnames.

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. An abstract pathname has
two components:

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.
The first name in an abstract pathname may be a directory name or, in the case of Microsoft Windows UNC
pathnames, a hostname. Each subsequent name in an abstract pathname denotes a directory; the last name
may denote either a directory or a file. The empty abstract pathname has no prefix and an empty name
sequence.

The conversion of a pathname string to or from an abstract pathname is inherently system-dependent. When an
abstract pathname is converted into a pathname string, each name is separated from the next by a single copy
of the default separator character. The default name-separator character is defined by the system property
file.separator, and is made available in the public static fields separator and separatorChar of
this class. When a pathname string is converted into an abstract pathname, the names within it may be
separated by the default name-separator character or by any other name-separator character that is supported
by the underlying system.

A pathname, whether abstract or in string form, may be either absolute or relative. An absolute pathname is
complete in that no other information is required in order to locate the file that it denotes. A relative pathname, in
contrast, must be interpreted in terms of information taken from some other pathname. By default the classes in
the java.io package always resolve relative pathnames against the current user directory. This directory is
named by the system property user.dir, and is typically the directory in which the Java virtual machine was
invoked.

The parent of an abstract pathname may be obtained by invoking the getParent() method of this class and
consists of the pathname's prefix and each name in the pathname's name sequence except for the last. Each
directory's absolute pathname is an ancestor of any File object with an absolute abstract pathname which
begins with the directory's absolute pathname. For example, the directory denoted by the abstract pathname
"/usr" is an ancestor of the directory denoted by the pathname "/usr/local/bin".

https://docs.oracle.com/javase/7/docs/api/java/io/File.html 19/12/24, 10 32 PM
Page 1 of 34
:

You might also like