API Overview API Index Package Overview Direct link to this page
JDK 1.6
  java.io. File View Source
Author(s)
unascribed
Since
JDK1.0
Version
1.140, 03/09/07
Serial
Hierarchy
 Object
      File
Implements
 Serializable
 Comparable
Subclasses
Description
public class File
  An abstract representation of file and directory pathnames.
See also:   
Constructors
public File (File parent, String child)
  Creates a new File instance from a parent abstract pathname and a child pathname string.
public File (String pathname)
  Creates a new File instance by converting the given pathname string into an abstract pathname.
private File (String child, File parent)
  Internal constructor for already-normalized pathname strings.
private File (String pathname, int prefixLength)
Internal constructor for already-normalized pathname strings.
public File (String parent, String child)
  Creates a new File instance from a parent pathname string and a child pathname string.
public File (URI uri)
  Creates a new File instance by converting the given file: URI into an abstract pathname.
Methods
Hide/Show inherited methods
public boolean canExecute ()
  Tests whether the application can execute the file denoted by this abstract pathname.
public boolean canRead ()
  Tests whether the application can read the file denoted by this abstract pathname.
public boolean canWrite ()
  Tests whether the application can modify the file denoted by this abstract pathname.
public int compareTo (File pathname)
  Compares two abstract pathnames lexicographically.
public boolean createNewFile () throws IOException
  Atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist.
publicstatic File createTempFile (String prefix, String suffix) throws IOException
  Creates an empty file in the default temporary-file directory, using the given prefix and suffix to generate its name.
publicstatic File createTempFile (String prefix, String suffix, File directory) throws IOException
  Creates a new empty file in the specified directory, using the given prefix and suffix strings to generate its name.
public boolean delete ()
  Deletes the file or directory denoted by this abstract pathname.
public void deleteOnExit ()
  Requests that the file or directory denoted by this abstract pathname be deleted when the virtual machine terminates.
public boolean equals (Object obj)
  Tests this abstract pathname for equality with the given object.
public boolean exists ()
  Tests whether the file or directory denoted by this abstract pathname exists.
public File getAbsoluteFile ()
  Returns the absolute form of this abstract pathname.
public String getAbsolutePath ()
  Returns the absolute pathname string of this abstract pathname.
public File getCanonicalFile () throws IOException
  Returns the canonical form of this abstract pathname.
public String getCanonicalPath () throws IOException
  Returns the canonical pathname string of this abstract pathname.
public long getFreeSpace ()
  Returns the number of unallocated bytes in the partition named by this abstract path name.
public String getName ()
  Returns the name of the file or directory denoted by this abstract pathname.
public String getParent ()
  Returns the pathname string of this abstract pathname's parent, or null if this pathname does not name a parent directory.
public File getParentFile ()
  Returns the abstract pathname of this abstract pathname's parent, or null if this pathname does not name a parent directory.
public String getPath ()
  Converts this abstract pathname into a pathname string.
pack-private int getPrefixLength ()
  Returns the length of this abstract pathname's prefix.
public long getTotalSpace ()
  Returns the size of the partition named by this abstract pathname.
public long getUsableSpace ()
  Returns the number of bytes available to this virtual machine on the partition named by this abstract pathname.
public int hashCode ()
  Computes a hash code for this abstract pathname.
public boolean isAbsolute ()
  Tests whether this abstract pathname is absolute.
public boolean isDirectory ()
  Tests whether the file denoted by this abstract pathname is a directory.
public boolean isFile ()
  Tests whether the file denoted by this abstract pathname is a normal file.
public boolean isHidden ()
  Tests whether the file named by this abstract pathname is a hidden file.
public long lastModified ()
  Returns the time that the file denoted by this abstract pathname was last modified.
public long length ()
  Returns the length of the file denoted by this abstract pathname.
public String list ()
  Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.
public String list (FilenameFilter filter)
  Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.
public File listFiles ()
  Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.
public File listFiles (FileFilter filter)
  Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.
public File listFiles (FilenameFilter filter)
  Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.
publicstatic File listRoots ()
  List the available filesystem roots.
public boolean mkdir ()
  Creates the directory named by this abstract pathname.
public boolean mkdirs ()
  Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories.
public boolean renameTo (File dest)
  Renames the file denoted by this abstract pathname.
public boolean setExecutable (boolean executable)
  A convenience method to set the owner's execute permission for this abstract pathname.
public boolean setExecutable (boolean executable, boolean ownerOnly)
  Sets the owner's or everybody's execute permission for this abstract pathname.
public boolean setLastModified (long time)
  Sets the last-modified time of the file or directory named by this abstract pathname.
public boolean setReadable (boolean readable)
  A convenience method to set the owner's read permission for this abstract pathname.
public boolean setReadable (boolean readable, boolean ownerOnly)
  Sets the owner's or everybody's read permission for this abstract pathname.
public boolean setReadOnly ()
  Marks the file or directory named by this abstract pathname so that only read operations are allowed.
public boolean setWritable (boolean writable)
  A convenience method to set the owner's write permission for this abstract pathname.
public boolean setWritable (boolean writable, boolean ownerOnly)
  Sets the owner's or everybody's write permission for this abstract pathname.
public String toString ()
  Returns the pathname string of this abstract pathname.
public URI toURI ()
  Constructs a file: URI that represents this abstract pathname.
@Deprecated
public URL toURL () throws MalformedURLException
  Converts this abstract pathname into a file: URL.
Fields
Hide/Show inherited fields
publicfinalstatic String pathSeparator
  The system-dependent path-separator character, represented as a string for convenience.
publicfinalstatic char pathSeparatorChar
  The system-dependent path-separator character.
publicfinalstatic String separator
  The system-dependent default name-separator character, represented as a string for convenience.
publicfinalstatic char separatorChar
  The system-dependent default name-separator character.
Nested Classes
Generated By: JavaOnTracks Doclet 0.1.4     ©Thibaut Colar