zoukankan      html  css  js  c++  java
  • File类

    构造器:

    File(File parent, String child)
    Creates a new File instance from a parent abstract pathname and a child pathname string.
    File(String pathname)
    Creates a new File instance by converting the given pathname string into an abstract pathname.
    File(String parent, String child)
    Creates a new File instance from a parent pathname string and a child pathname string.
    File(URI uri)

    常用方法:

    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 if and only if a file with this name does not yet exist.
    static File createTempFile(String prefix, String suffix)
    Creates an empty file in the default temporary-file directory, using the given prefix and suffix to generate its name.
    static File createTempFile(String prefix, String suffix, File directory)
    Creates a new empty file in the specified directory, using the given prefix and suffix strings to generate its name.
    boolean delete()
    Deletes the file or directory denoted by this abstract pathname.
    void deleteOnExit()
    Requests that the file or directory denoted by this abstract pathname be deleted when the virtual machine terminates.
    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.
    File getAbsoluteFile()
    Returns the absolute form of this abstract pathname.
    String getAbsolutePath()
    Returns the absolute pathname string of this abstract pathname.
    File getCanonicalFile()
    Returns the canonical form of this abstract pathname.
    String getCanonicalPath()
    Returns the canonical pathname string of this abstract pathname.
    long getFreeSpace()
    Returns the number of unallocated bytes in the partition named by this abstract path name.
    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, or null if this pathname does not name a parent directory.
    File getParentFile()
    Returns the abstract pathname of this abstract pathname's parent, or null if this pathname does not name a parent directory.
    String getPath()
    Converts this abstract pathname into a pathname string.
    long getTotalSpace()
    Returns the size of the partition named by this abstract pathname.
    long getUsableSpace()
    Returns the number of bytes available to this virtual machine on the partition named by this abstract pathname.
    int hashCode()
    Computes a hash code for this abstract pathname.
    boolean isAbsolute()
    Tests whether this abstract pathname is absolute.
    boolean isDirectory()
    Tests whether the file denoted by this abstract 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 lastModified()
    Returns the time that the file denoted by this abstract pathname was last modified.
    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 denoted by this abstract pathname.
    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.
    File[] listFiles()
    Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.
    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.
    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.
    static File[] listRoots()
    List the available filesystem roots.
    boolean mkdir()
    Creates the directory named by this abstract pathname.
    boolean mkdirs()
    Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories.
    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 for this abstract pathname.
    boolean setExecutable(boolean executable, boolean ownerOnly)
    Sets the owner's or everybody's execute permission for this abstract pathname.
    boolean setLastModified(long time)
    Sets the last-modified time of the file or directory named by this abstract pathname.
    boolean setReadable(boolean readable)
    A convenience method to set the owner's read permission for this abstract pathname.
    boolean setReadable(boolean readable, boolean ownerOnly)
    Sets the owner's or everybody's read permission for this abstract pathname.
    boolean setReadOnly()
    Marks the file or directory named by this abstract pathname so that only read operations are allowed.
    boolean setWritable(boolean writable)
    A convenience method to set the owner's write permission for this abstract pathname.
    boolean setWritable(boolean writable, boolean ownerOnly)
    Sets the owner's or everybody's write permission for this abstract pathname.
    Path toPath()
    Returns a java.nio.file.Path object constructed from the this abstract path.
    String toString()
    Returns the pathname string of this abstract pathname.
    URI toURI()
    Constructs a file: URI that represents this abstract pathname.
    URL toURL()
    Deprecated. 
    This method does not automatically escape characters that are illegal in URLs. It is recommended that new code convert an abstract pathname into a URL by first converting it into a URI, via the toURI method, and then converting the URI into a URL via the URI.toURL method.
  • 相关阅读:
    SQL SERVER CXPACKET-Parallelism Wait Type 的惯用解决方案
    服务器主体 "sa" 无法在当前安全上下文下访问数据库 XXX[SQLSTATE 08004] (错误 916). 该步骤失败。
    Android 使用 aapt 命令查看 apk 包名
    Android数据库GreenDao的使用总结
    NestedScrollView、ScrollView 加载完自动滑动至底部问题的解决方案
    Android框架式编程之Retrofit
    Visual Studio 开发(三):Visual Studio 使用时常见问题解决方案
    Android 网络交互之移动端与服务端的加密处理
    Android框架式编程之ViewModel
    Android框架式编程之LiveData
  • 原文地址:https://www.cnblogs.com/ChuPengcheng/p/6108772.html
Copyright © 2011-2022 走看看