0% found this document useful (0 votes)
43 views

Java - Io Class File: Throws

The File class represents files and directories on the file system. It allows methods to check, create, delete and modify files as well as get information like name, path, length, and timestamps. The class extends Object and provides constructors to create File objects from strings, URIs, and other Files. It also includes methods to get canonical paths, URLs, compare files, and check file attributes.

Uploaded by

achuppi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

Java - Io Class File: Throws

The File class represents files and directories on the file system. It allows methods to check, create, delete and modify files as well as get information like name, path, length, and timestamps. The class extends Object and provides constructors to create File objects from strings, URIs, and other Files. It also includes methods to get canonical paths, URLs, compare files, and check file attributes.

Uploaded by

achuppi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

java.

io
Class File
java.lang.Object
|
+--java.lang.File
public final class File extends Object
Constructor Summary
File (File parent, String child)
Creates a new File instance from a parent abstract
pathname and a child pathname string.
Throws : NullPointerException - If child is null
File(String pathname)
Creates a new File instance by converting the given
pathname string into an abstract pathname.
Throws: NullPointerException - If the pathname argument
is null
File(String parent, String child)
Creates a new File instance from a parent pathname
string and a child pathname string.
Throws: NullPointerException - If child is null
File(URI uri)
Creates a new File instance by converting the
given file: URI into an abstract pathname.
Throws: NullPointerException - If uri is null

IllegalArgumentException - If the preconditions on the


parameter do not hold

Method Summary

public String getName()


public String getParent()
public File getParentFile()
public String getPath()
public boolean isAbsolute()
public String getAbsolutePath()

Throws: SecurityException - If a required system property


value cannot be accessed.
public File getAbsoluteFile()
Throws: SecurityException - If a required system property
value cannot be accessed.
public String getCanonicalPath()
IOException - If an I/O error occurs, this is possible because the
construction of the canonical pathname may require filesystem
queries.
SecurityException - If a required system property value cannot
be accessed.
public File getCanonicalFile() throws IOException
IOException - If an I/O error occurs, this is possible because
the construction of the canonical pathname may require filesystem
queries.

SecurityException - If a required system property value


cannot be accessed.
@Deprecated
public URL toURL() throws MalformedURLException
Throws: MalformedURLException - If the path cannot be
parsed as a URL.
public URI toURI()
Throws: SecurityException - If a required system property
value cannot be accessed.
public boolean canRead() Throws: SecurityException
public boolean canWrite()Throws: SecurityException
public boolean exists() Throws: SecurityException
public boolean isDirectory() Throws SecurityException
public boolean isFile() Throws SecurityException
public boolean isHidden() Throws SecurityException
public long lastModified() Throws SecurityException
public long length() Throws SecurityException
public boolean createNewFile() Throws: IOException,
SecurityException
public boolean delete()Throws SecurityException
public void deleteOnExit()Throws SecurityException
public String[] list()Throws SecurityException
public String[] list(FilenameFilter filter) Throws
SecurityException
public File[] listFiles()Throws SecurityException
public File[] listFiles(FilenameFilter filter) Throws
SecurityException
public File[] listFiles(FileFilter filter) Throws
SecurityException

public boolean mkdir()Throws SecurityException


public boolean mkdirs()Throws SecurityException
public boolean renameTo(File dest) Throws SecurityException
Null Pointer Exception : If parameter dest is null
public boolean setLastModified(long time)Throws
IllegalArgumentException - If the argument is negative
public boolean setReadOnly()Throws SecurityException
public boolean setWritable(boolean writable,
boolean ownerOnly)
Throws SecurityException
public boolean setWritable(boolean writable)
ThrowSecurityException
public boolean setReadable(boolean readable,boolean ownerOnl
y)
Throw SecurityException
public boolean setReadable(boolean readable) Throw
SecurityException
public boolean setExecutable(boolean executable,
boolean ownerOnly)
Throw SecurityException
public boolean setExecutable(boolean executable) Throw
SecurityException
public boolean canExecute()Throw SecurityException
public static File[] listRoots()
public long getTotalSpace() Throw SecurityException
public long getFreeSpace() Throw SecurityException
public long getUsableSpace()Throw SecurityException
publicstatic File createTempFile(String prefix,String suffix,File
director)
Throws: IllegalArgumentException - If the prefix argument
contains fewer than three character IOException - If a file could
not be created, SecurityException
public static File createTempFile(String prefix, String suffix)

Throws: IllegalArgumentException - If the prefix argument


contains fewer than three character IOException - If a file could
not be created, SecurityException
public int compareTo(File pathname)
public boolean equals(Object obj)
public int hashCode()
public String toString()
public Path toPath() Throws : InvalidPathException - if
a Path object cannot be constructed from the abstract path .

You might also like