导入包import java.io.File;
- 构造函数
- File(pathname : String)
- File(parent : String, child : String) //为目录parent下的child创建一个File对象,这个Child是一个文件名也可以是一个子目录
- File(parent : File, child : String)
- 获取文件性质
- exists() : boolean
- canRead() : boolean
- canWrite() : boolean
- isDirectory() : boolean // 如果File对象表示一个目录则返回true
- isFile() : boolean
- isAbsolute() : boolean //如果File是由决定路径创建的,则返回true
- isHidden() : boolean // 如果File对象中表示的文件被隐藏则返回true。被隐藏的确切定义是依赖系统的。在Windows系统中,可以在文件属性对话框中标记该文件为隐藏的。在UNIX系统中,如果文件名以句号字符“ . ”开始则隐藏文件
- 获取文件信息
- getAbsolutePath() : String
- getCanonicalPath() : String
- getName() : String
- getParent() : String
- lastModified() : long //返回文件最后一次修改的时间
- length() : long
- listFile() : File[] //返回一个File对象目录下的文件
- delete() : boolean //
- renameTo(dest : File) : boolean