DthingApi
Public Member Functions | Static Public Attributes | List of all members
java.io.File Class Reference
Inheritance diagram for java.io.File:
java.io.Serializable

Public Member Functions

 File (String pathname)
 
boolean createNewFile () throws IOException
 
boolean delete ()
 
boolean exists ()
 
String getPath ()
 
boolean isDirectory ()
 
boolean isFile ()
 
long lastModified ()
 
long length ()
 
File [] listFiles ()
 
long totalSize ()
 
long availableSize ()
 
String toString ()
 

Static Public Attributes

static final String separator
 

Detailed Description

A representation of file and directory pathnames.

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

Each name part of a pathname string 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.

A pathname must be absolute. An absolute pathname is complete in that no other information is required in order to locate the file that it denotes.

Instances of the File class are immutable; that is, once created, the pathname represented by a File object will never change.

Constructor & Destructor Documentation

◆ File()

java.io.File.File ( String  pathname)
inline

Creates a new File instance with the given absolute pathname string. If the given string is the empty string, then the result is the empty absolute pathname.

Parameters
pathnameA pathname string
Exceptions
NullPointerExceptionIf the pathname argument is null

Member Function Documentation

◆ createNewFile()

boolean java.io.File.createNewFile ( ) throws IOException
inline

Atomically creates a new, empty file named by this absolute pathname if and only if a file with this name does not yet exist. The check for the existence of the file and the creation of the file if it does not exist are a single operation that is atomic with respect to all other filesystem activities that might affect the file.

Returns
true if the named file does not exist and was successfully created; false if the named file already exists
Exceptions
IOExceptionIf an I/O error occurred

◆ delete()

boolean java.io.File.delete ( )
inline

Deletes the file or directory denoted by this absolute pathname. If this pathname denotes a directory, then the directory must be empty in order to be deleted.

Returns
true if and only if the file or directory is successfully deleted; false otherwise

◆ exists()

boolean java.io.File.exists ( )
inline

Tests whether the file or directory denoted by this absolute pathname exists.

Returns
true if and only if the file or directory denoted by this absolute pathname exists; false otherwise

◆ getPath()

String java.io.File.getPath ( )
inline
Returns
The string form of this absolute pathname

◆ isDirectory()

boolean java.io.File.isDirectory ( )
inline

Tests whether the file denoted by this absolute pathname is a directory.

Returns
true if and only if the file denoted by this absolute pathname exists and is a directory; false otherwise

◆ isFile()

boolean java.io.File.isFile ( )
inline

Tests whether the file denoted by this absolute pathname is a normal file. A file is normal if it is not a directory and, in addition, satisfies other system-dependent criteria. Any non-directory file created by a Java application is guaranteed to be a normal file.

Returns
true if and only if the file denoted by this absolute pathname exists and is a normal file; false otherwise

◆ lastModified()

long java.io.File.lastModified ( )
inline

Returns the time that the file denoted by this absolute pathname was last modified.

Returns
A long value representing the time the file was last modified, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970), or 0L if the file does not exist or if an I/O error occurs

◆ length()

long java.io.File.length ( )
inline

Returns the length of the file denoted by this absolute pathname. The return value is unspecified if this pathname denotes a directory.

Returns
The length, in bytes, of the file denoted by this absolute pathname, or 0L if the file does not exist. Some operating systems may return 0L for pathnames denoting system-dependent entities such as devices or pipes.

◆ listFiles()

File [] java.io.File.listFiles ( )
inline

Returns an array of absolute pathnames denoting the files in the directory denoted by this absolute pathname.

If this absolute pathname does not denote a directory, then this method returns

null

. Otherwise an array of

objects is returned, one for each file or directory in the directory. Pathnames denoting the directory itself and the directory's parent directory are not included in the result.

There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.

Returns
An array of absolute pathnames denoting the files and directories in the directory denoted by this absolute pathname. The array will be empty if the directory is empty. Returns
null
if this absolute pathname does not denote a directory, or if an I/O error occurs.

◆ toString()

String java.io.File.toString ( )
inline

Returns the pathname string of this absolute pathname. This is just the string returned by the getPath method.

Returns
The string form of this absolute pathname

Member Data Documentation

◆ separator

final String java.io.File.separator
static
Initial value:
=
(Platform.getPlatform() == Platform.PLAT_UNIX) ? "/" : "\\"

The documentation for this class was generated from the following file: