java files

By | October 14, 2019

File class is present in java.io package and we can work with File class to read or write data.

Below are the methods present in File class.

 

Method Type Description
length() String Returns the length of the file.
canRead() Boolean Tests whether the file is readable or not.
canWrite() Boolean Tests whether the file is writable or not.
delete() Boolean Deletes a file or directory.
createNewFile() Boolean Creates a new empty file.
exists() Boolean Tests whether a file or directory exists or not.
compareTo(File filePath) int Compares two path names.
getParent() String It returns the pathname of the parent folder.
getName() Returns file name. Returns the name of the file
mkdir() Boolean Creates a directory

Leave a Reply

Your email address will not be published. Required fields are marked *