Computer Science, asked by namazzisalmah108, 11 months ago

How many methods are available in java for file class that can be used to perform various operation

Answers

Answered by suneelgoli
0

Answer:

The File class contains several methods for working with the path name, deleting and renaming files, creating new directories, listing the contents of a directory, and determining several common attributes of files and directories.

Methods

  • boolean canExecute() : Tests whether the application can execute the file denoted by this abstract pathname.
  • boolean canRead() : Tests whether the application can read the file denoted by this abstract pathname.
  • boolean canWrite() : Tests whether the application can modify the file denoted by this abstract pathname.
  • int compareTo(File pathname) : Compares two abstract pathnames lexicographically.
  • boolean createNewFile() : Atomically creates a new, empty file named by this abstract pathname .
  • static File createTempFile(String prefix, String suffix) : Creates an empty file in the default temporary-file directory.
  • boolean delete() : Deletes the file or directory denoted by this abstract pathname.
  • boolean equals(Object obj) : Tests this abstract pathname for equality with the given object.
  • boolean exists() : Tests whether the file or directory denoted by this abstract pathname exists.
  • String getAbsolutePath() : Returns the absolute pathname string of this abstract pathname.
  • long getFreeSpace() : Returns the number of unallocated bytes in the partition .
  • String getName() : Returns the name of the file or directory denoted by this abstract pathname.
  • String getParent() : Returns the pathname string of this abstract pathname’s parent.
  • File getParentFile() : Returns the abstract pathname of this abstract pathname’s parent.
  • String getPath() : Converts this abstract pathname into a pathname string.
  • boolean isDirectory() : Tests whether the file denoted by this pathname is a directory.
  • boolean isFile() : Tests whether the file denoted by this abstract pathname is a normal file.
  • boolean isHidden() : Tests whether the file named by this abstract pathname is a hidden file.
  • long length() : Returns the length of the file denoted by this abstract pathname.
  • String[] list() : Returns an array of strings naming the files and directories in the directory .
  • File[] listFiles() : Returns an array of abstract pathnames denoting the files in the directory.
  • boolean mkdir() : Creates the directory named by this abstract pathname.
  • boolean renameTo(File dest) : Renames the file denoted by this abstract pathname.
  • boolean setExecutable(boolean executable) : A convenience method to set the owner’s execute permission.
  • boolean setReadable(boolean readable) : A convenience method to set the owner’s read permission.
  • boolean setReadable(boolean readable, boolean ownerOnly) : Sets the owner’s or everybody’s read permission.
  • boolean setReadOnly() : Marks the file or directory named so that only read operations are allowed.
  • boolean setWritable(boolean writable) : A convenience method to set the owner’s write permission.
  • String toString() : Returns the pathname string of this abstract pathname.
  • URI toURI() : Constructs a file URI that represents this abstract pathname.
Similar questions