File
The File
class is designed to handle file-related operations, providing methods for managing file properties and interactions.
Constructor
constructor(filePath: String)
constructor(filePath: String)
Creates an instance of the File
class representing a specific file path.
filePath
(String): The file path for which theFile
instance is created.
Methods
getAbsolutePath(): String
Retrieves the absolute path of the file, including the file's name.
exists(): Boolean
Checks if the file exists and returns true if it exists, otherwise false.
isFile(): Boolean
Determines whether the object represents a file (as opposed to a directory) and returns true for a file, false otherwise.
isDirectory(): Boolean
Determines whether the object represents a directory and returns true for a directory, false otherwise.
lastModified(): Long
Gets the timestamp indicating the last modification time of the file, typically in milliseconds since the epoch. The return type is "Long."
delete(): Boolean
Attempts to delete the file and returns true if the deletion was successful, and false if it failed.
getName(): String
Retrieves the name of the file (without the path) as a string.
getParent(): String
Gets the parent directory's path as a string.
getParentFile(): File
Returns a new File object representing the parent directory of the current file.
getPath(): String
Retrieves the path of the file (including its name) as a string.
For a more comprehensive overview, you can explore the FileUtil class to delve into the full range of available methods.
Last updated