Java中的File与IO流
- 文件和IO所在的逻辑包
java.io.*;
- java中的File
File表示的是文件和目录路径名的抽象表示;
File的构造方法:
File(String pathname):通过将给定的路径名字符串转换为抽象路径名来创建新的File实例
File(File parent,String child):从父抽象路径名和子抽象路径名字符串来创建新的File实例
File(String parent,String child):从父路径名字符串和子路径字符串创建新的File实例
File(URI uri):通过将给定的URI转换为抽象路径来创建行的File实例
File中的常用方法
boolean | canRead() |
boolean | canWrite() |
int | compareTo(File pathname) |
boolean | createNewFile() |
static File | createTempFile(String prefix, String suffix) |
static File | createTempFile(String prefix, String suffix, File directory) |
boolean | delete() |
void | deleteOnExit() |
boolean | equals(Object obj) |
boolean | exists() |
File | getAbsoluteFile() |
String | getAbsolutePath() |
File | getCanonicalFile() |
String | getCanonicalPath() |
String | getName() |
String | getParent() |
File | getParentFile() |
String | getPath() |
int | hashCode() |
boolean | isAbsolute() |
boolean | isDirectory() |
boolean | isFile() |
boolean | isHidden() |
long | lastModified() |
long | length() |
String[] | list() |
String[] | list(FilenameFilter filter) |
File[] | listFiles() |
File[] | listFiles(FileFilter filter) |
File[] | listFiles(FilenameFilter filter) |
static File[] | listRoots() |
boolean | mkdir() |
boolean | mkdirs() |
boolean | renameTo(File dest) |
boolean | setLastModified(long time) |
boolean | setReadOnly() |
String | toString() |
URI | toURI() |
URL | toURL() |
- 输入流与输出流