File class methods in Java Set -2

java.io.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.

2. A sequence of zero or more string names.


Some methods of File class.

lastModified()This method returns the time that the file denoted by this abstract pathname was last modified.

length()This method returns the length of the file denoted by this abstract pathname. The return value is unspecified if this pathname denotes a directory.

list(): This method returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.

list(FilenameFilter): This method returns an array of strings naming the files and directories in the directory denoted by this abstract pathname that satisfies the specified filter.

listFiles(): This method returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.

listFiles(FileFilter): This method returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfies the specified filter.

listFiles(FilenameFilter)This method returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfies the specified filter.

mkdir()This method creates the directory named by this abstract pathname.

mkdirs()This method creates the directory named by this abstract pathname, including any necessary but non-existent parent directories.

File(File, String)This method creates a new File instance from a parent abstract pathname and a child pathname string.

File(String, String)This method creates a new File instance from a parent pathname string and a child pathname string.

File(String) This method creates a new File instance by converting the given pathname string into an abstract pathname.

renameTo(File)This method renames the file denoted by this abstract pathname.

setExecutable(boolean)This method is a convenient method to set the owner's execute permission for this abstract pathname.

setExecutable(boolean, boolean)This method sets the owner's or everybody's executing permission for this abstract pathname.

setLastModified(long)This method sets the last-modified time of the file or directory named by this abstract pathname.

setReadable(boolean)This method is a convenient method to set the owner's read permission for this abstract pathname.

setReadable(boolean, boolean)This method sets the owner's or everybody's read permission for this abstract pathname.

setReadOnly()This method marks the file or directory named by this abstract pathname so that only read operations are allowed.

setWritable(boolean)This method is a convenient method to set the owner's write permission for this abstract pathname.

setWritable(boolean, boolean)This method sets the owner's or everybody's writing permission for this abstract pathname.

toPath()This method returns a java.nio.file.Path object constructed from this abstract path.

toString()This method returns the pathname string of this abstract pathname.

toURI()This method constructs a file: URI that represents this abstract pathname.

File(URI)This method creates a new File instance by converting the given file: URI into an abstract pathname.


File class methods in Java Set -1

No comments:

Post a Comment