boolean canWrite() Returns true if the file or directory may be modified. : File « File « SCJP






import java.io.File;
public class MainClass{
  public static void main(String[] argv){
    
    
    File file = new File("c:\\test.dat");
    String[] fileNames = file.list();
    System.out.println(file.canWrite());

  }
}
false








9.1.File
9.1.1.java.io.File class represents the name of a file or directory that might exist on the file system.
9.1.2.File: boolean exists() Returns true if the file or directory exists; otherwise returns false.
9.1.3.File: String getAbsolutePath() Returns the absolute (that is, not relative) path of the file or directory.
9.1.4.File: String getCanonicalPath() Returns the canonical path of the file or directory.
9.1.5.File: String getName() Returns the name of the file or directory.
9.1.6.File: String getParent() Returns the name of the directory that contains the File.
9.1.7.File: boolean isDirectory() Returns true if the File object describes a directory that exists on the file system.
9.1.8.File: boolean isFile() Returns true if the File object describes a file that exists on the file system.
9.1.9.File: String[] list() Returns an array of the files and directories within the File instance.
9.1.10.File: boolean canRead() Returns true if the file or directory may be read.
9.1.11.boolean canWrite() Returns true if the file or directory may be modified.
9.1.12.boolean createNewFile() Creates a new empty file
9.1.13.boolean delete() Attempts to delete the file or directory.
9.1.14.long length() Returns the length of the file.
9.1.15.boolean mkdir() Attempts to create a directory whose path is described by the current instance of File.
9.1.16.boolean renameTo(Filenewname) Renames the file or directory.
9.1.17.Creating Files Using Class File