-
boolean canExecute(): This function returns true if the abstract pathname points to a file that is executable. If the file is not executable, it returns false.
-
boolean canRead() : This function returns true, if the program can read the file. This file is actually an abstract pathname. If it cannot read, it returns false.
-
boolean canWrite(): This boolean function returns true if it can write over the contents of the file. If not, it returns false.
-
int compareTo(File pathname): This function compares two pathnames lexicographically. Note that the path names are abstract. This function also returns the difference if these two pathnames are not identical.
-
boolean createNewFile(): This function creates a new file that is empty following the abstract pathname. If it cannot then it returns false.
-
static File createTempFile(String prefix, String suffix): As the name suggests this function creates a temporary file inside the default temporary file library.
-
boolean delete(): This function deletes the directory or the file denoted by the abstract pathname. It returns false if an exception occurs.
-
boolean equals(Object obj): This function checks whether the pathname is equal to the given object
-
boolean exists(): This method checks whether the file or directory is present or not. Returns true if found, else returns false.
-
String getAbsolutePath(): This function is responsible for returning the absolute path of the file.
-
long getFreeSpace(): This method is particularly useful when you want to find the number of unallocated bytes in the partition. This method returns a value of type long. If there is no space left, it returns “0L”
-
String getName(): This method, as the name signifies, is responsible for returning the name of the directory or file to which the pathname points.
-
File getParentFile(): This method has the sole responsibility of returning the abstract pathname of the current abstract pathnames parent. This simply means that the function returns the abstract pathname of the parent of the current file.
-
boolean isDirectory(): When you pass an abstract pathname to this function, this returns true if the pathname points to a directory and false otherwise.
-
boolean isFile(): This boolean method returns true if the pathname points to a file and false otherwise.
-
String getParent(): This method returns the string pathname of the file’s parent.
-
boolean isHidden(): This method checks if the path points to a hidden file and false otherwise. If it is hidden it returns true, else false.
-
String[] list(): This method generates a list of strings of all the filenames present in the directory.
-
File[] listFiles() :This method puts together an array and returns it. The array contains all the pathnames of the files present in the directory.
-
boolean mkdir(): This method creates a new directory with the abstract pathname.
-
boolean renameTo(File dest): This function has the responsibility of renaming the file of the abstract pathname.
-
long length(): This method is responsible for returning the length of the file. The return type is long.
-
boolean setExecutable(boolean executable): If you want to set the execute permission for the owner for this particular abstract pathname then this method becomes useful.
-
boolean setReadable(boolean readable): This method sets the owner’s read permission.
-
String getPath(): This method generates a pathname string from the abstract pathname.
-
boolean setReadable(boolean readable, boolean ownerOnly): Unlike the previous method, this method can set the read permission of the owner as well as everybody’s read permissions.
-
boolean setReadOnly(): This changes the edit access of the file to read-only. Once this method is executed, you cannot edit the file.
-
boolean setWritable(boolean writable): This method is responsible for setting the user’s write permission.