Android:java.io.File

来源:互联网 发布:淘宝皇冠店卖多少钱 编辑:程序博客网 时间:2024/06/05 06:50

 

An "abstract" representation of a file system entity identified by a pathname. The pathname may be absolute (relative to the root directory of the file system) or relative to the current directory in which the program is running.

对文件系统实体的一个抽象表现,用路径名来识别,可以使绝对路径也可以是相对路径

The actual file referenced by a File may or may not exist. It may also, despite the nameFile, be a directory or other non-regular file.

被File对象所引用的文件,可能存在也可能不存在。也可能是目录或其它不常见的文件

This class provides limited functionality for getting/setting file permissions, file type, and last modified time.

On Android strings are converted to UTF-8 byte sequences when sending filenames to the operating system, and byte sequences returned by the operating system (from the variouslist methods) are converted to strings by decoding them as UTF-8 byte sequences.

Android字符串与操作系统以UTF-8字节流的形式传递

Public ConstructorsFile(File dir, String name)

Constructs a new file using the specified directory(目录文件File) and name(文件名字符串).
File(String path)
Constructs a new file using the specified path(路径字符串).
File(String dirPath, String name)
Constructs a new File using the specified directory path(路径字符串) and file name(文件名字符串), placing a path separator(路径分隔符) between the two.
File(URI uri)
Constructs a new File using the path of the specified URI.

String[]list()
Returns an array of strings with the file names in the directory represented by this file.
当前文件如果是目录文件,返回此目录中的文件(字符串数组),如果当前文件不是目录文件,返回NULL。
表示当前目录的(.)和表示父目录的(..)不作为数组的一部分返回。
String[]list(FilenameFilter filter)
Gets a list of the files in the directory represented by this file.
File[]listFiles()
Returns an array of files contained in the directory represented by this file.
返回当前目录中的文件(文件数组)。当前路径如果是绝对路径,返回的文件也是绝对路径。当前路径如果是相对路径,返回的文件也是相对路径。
File[]listFiles(FilenameFilter filter)
Gets a list of the files in the directory represented by this file.
File[]listFiles(FileFilter filter)
Gets a list of the files in the directory represented by this file.
static File[]listRoots()
Returns the file system roots.

boolean

mkdir()
Creates the directory named by this file, assuming its parents exist.
根据当前目录文件名创建目录文件,假定上级目录存在
booleanmkdirs()
Creates the directory named by this file, creating missing parent directories if necessary.
创建缺失的上级目录
原创粉丝点击