1:核心类
| 类 | 说明 |
|---|---|
| File | 文件类 |
| InputString | 字节输入流 |
| OutputString | 字节输出流 |
| Reader | 字符输入流 |
| Writer | 字符输出流 |
| Closeable | 关闭流接口 |
| Flushable | 刷新流接口 |
| Serializable | 序列化接口 |
2:File.
| Constructor | 描述 |
| File(File parent , String child) | 从父抽象路径和自路径名字符串创建的File实例 |
| File(String pathname) | 通过将给定的路径名字符串换为抽象路径来创建新的File实例 |
| File(String parent , String child) | 从父路径名字符串和子路径名字符串创建新的File实例 |
| File(URI uri) | 通过将给定的file:URI转换为路径名来创建新的File实例 |
例:构建File对象的三种方法
String path = "D:/text/text.txt"; //建议使用"/"
//构建File对象,方法一:
File scr = new File(path);
System.out.println(scr.length());
//方法二:
scr = new File("D:/text","text.txt");
System.out.println(scr.length());
//方法三:
scr = new File(new File("D:/text"),"text.txt");
System.out.println(scr.length());
3:API的使用
| API | 说明 |
| pathSeparator | 路径|路径分隔符 |
| File(String parent,String chile) File(File parent, String child) File(String name) | 构造器 没有盘符以user.dir作为相对目录 |
| getName() getPath() getAbsolutePath() getParent() | 文件名、路径名 |
| exists() isFile() isDirectory() | 判断状态 |
| length() | 文件长度 |
| createNewFile() delete() | 创建新文件,删除文件 |
| mkdir() mkdirs() | 创建目录,如果父目录链不存在一同创建 |
| list() | 下级名称 |
| listFiles | 下级File |
| listRoots | 根目录 |



