软件包 | 描述 |
---|---|
java.io |
通过数据流、序列化和文件系统提供系统的输入和输出。
|
java.nio.channels |
定义了渠道,它代表的是能够执行I/O操作的实体连接,如文件和套接字;定义选择器,多路复用,非阻塞I/O操作。
|
java.nio.file |
定义的接口和类的java虚拟机访问文件,文件属性,文件系统。
|
java.nio.file.spi |
为
java.nio.file 包服务提供商类。
|
java.util |
包含集合框架、遗留的集合类、事件模型、日期和时间的设施、国际化和各种实用工具类(一个字符串标记,一个随机数发生器,和一位阵列)。
|
Modifier and Type | Method and Description |
---|---|
Path |
File.toPath()
返回一个
java.nio.file.Path 对象由抽象路径。
|
Modifier and Type | Method and Description |
---|---|
static AsynchronousFileChannel |
AsynchronousFileChannel.open(Path file, OpenOption... options)
打开或创建一个用于读取和/或写入的文件,返回一个异步文件通道来访问该文件。
|
static FileChannel |
FileChannel.open(Path path, OpenOption... options)
打开或创建一个文件,返回一个文件通道来访问该文件。
|
static AsynchronousFileChannel |
AsynchronousFileChannel.open(Path file, Set<? extends OpenOption> options, ExecutorService executor, FileAttribute<?>... attrs)
打开或创建一个用于读取和/或写入的文件,返回一个异步文件通道来访问该文件。
|
static FileChannel |
FileChannel.open(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs)
打开或创建一个文件,返回一个文件通道来访问该文件。
|
Modifier and Type | Field and Description |
---|---|
static WatchEvent.Kind<Path> |
StandardWatchEventKinds.ENTRY_CREATE
创建的目录条目。
|
static WatchEvent.Kind<Path> |
StandardWatchEventKinds.ENTRY_DELETE
目录条目已删除。
|
static WatchEvent.Kind<Path> |
StandardWatchEventKinds.ENTRY_MODIFY
目录条目修改。
|
Modifier and Type | Method and Description |
---|---|
static Path |
Files.copy(Path source, Path target, CopyOption... options)
将一个文件复制到目标文件。
|
static Path |
Files.createDirectories(Path dir, FileAttribute<?>... attrs)
创建一个目录,通过创建所有不存在的父目录。
|
static Path |
Files.createDirectory(Path dir, FileAttribute<?>... attrs)
创建一个新目录。
|
static Path |
Files.createFile(Path path, FileAttribute<?>... attrs)
创建一个新的和空的文件,如果文件已经存在,失败了。
|
static Path |
Files.createLink(Path link, Path existing)
创建一个新的链接(目录项)为现有的文件(可选操作)。
|
static Path |
Files.createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs)
创建一个符号链接到一个目标(可选操作)。
|
static Path |
Files.createTempDirectory(Path dir, String prefix, FileAttribute<?>... attrs)
在指定的目录中创建一个新的目录,使用给定的前缀来生成它的名称。
|
static Path |
Files.createTempDirectory(String prefix, FileAttribute<?>... attrs)
在默认的临时文件目录中创建一个新目录,使用给定的前缀生成它的名称。
|
static Path |
Files.createTempFile(Path dir, String prefix, String suffix, FileAttribute<?>... attrs)
在指定的目录中创建一个新的空文件,使用给定的前缀和后缀字符串来生成它的名称。
|
static Path |
Files.createTempFile(String prefix, String suffix, FileAttribute<?>... attrs)
在默认的临时文件目录中创建一个空文件,使用给定的前缀和后缀来生成它的名称。
|
static Path |
Paths.get(String first, String... more)
将路径字符串,或一个字符串序列,当加入形成路径字符串,一个
Path 。
|
static Path |
Paths.get(URI uri)
将给定的URI的一
Path 对象。
|
Path |
Path.getFileName()
返回文件名或目录用该路径作为
Path 对象。
|
Path |
Path.getName(int index)
返回一个名字元这条道路作为一个
Path 对象。
|
Path |
Path.getParent()
返回父路径,或
null 如果这条路没有父。
|
abstract Path |
FileSystem.getPath(String first, String... more)
将路径字符串,或一个字符串序列,当加入形成路径字符串,一个
Path 。
|
Path |
Path.getRoot()
返回该路径的根组件作为一个
Path 对象,或
null 如果这条路没有根组件。
|
static Path |
Files.move(Path source, Path target, CopyOption... options)
移动或重命名一个文件到目标文件。
|
Path |
Path.normalize()
返回一个路径,这是一个冗余的名称元素消除的路径。
|
static Path |
Files.readSymbolicLink(Path link)
读一个符号链接的目标(可选操作)。
|
Path |
Path.relativize(Path other)
在这个路径和一个给定路径之间构造一个相对路径。
|
Path |
Path.resolve(Path other)
解决此路径的给定路径。
|
Path |
Path.resolve(String other)
|
Path |
Path.resolveSibling(Path other)
解决给定的路径在路径的
parent 路径。
|
Path |
Path.resolveSibling(String other)
|
static Path |
Files.setAttribute(Path path, String attribute, Object value, LinkOption... options)
设置文件属性的值。
|
static Path |
Files.setLastModifiedTime(Path path, FileTime time)
更新一个文件的最后一次修改的时间属性。
|
static Path |
Files.setOwner(Path path, UserPrincipal owner)
更新文件所有者。
|
static Path |
Files.setPosixFilePermissions(Path path, Set<PosixFilePermission> perms)
设置文件的POSIX权限。
|
Path |
Path.subpath(int beginIndex, int endIndex)
返回一个相对
Path 是子的这条道路的名称的元素。
|
Path |
Path.toAbsolutePath()
返回一个表示该路径绝对路径
Path 对象。
|
Path |
Path.toRealPath(LinkOption... options)
返回一个现有文件的真正路径。
|
static Path |
Files.walkFileTree(Path start, FileVisitor<? super Path> visitor)
走一个文件树。
|
static Path |
Files.walkFileTree(Path start, Set<FileVisitOption> options, int maxDepth, FileVisitor<? super Path> visitor)
走一个文件树。
|
static Path |
Files.write(Path path, byte[] bytes, OpenOption... options)
将字节写入到文件中。
|
static Path |
Files.write(Path path, Iterable<? extends CharSequence> lines, Charset cs, OpenOption... options)
写入文本到文件的行。
|
static Path |
Files.write(Path path, Iterable<? extends CharSequence> lines, OpenOption... options)
写入文本到文件的行。
|
Modifier and Type | Method and Description |
---|---|
static Stream<Path> |
Files.find(Path start, int maxDepth, BiPredicate<Path,BasicFileAttributes> matcher, FileVisitOption... options)
返回一个
Stream ,懒洋洋地填充
Path 寻找一根在一个给定的启动文件树文件。
|
abstract Iterable<Path> |
FileSystem.getRootDirectories()
返回一个对象遍历根目录的路径。
|
Iterator<Path> |
Path.iterator()
返回此路径的名称元素的迭代器。
|
static Stream<Path> |
Files.list(Path dir)
返回一个懒洋洋的密集
Stream ,其中的元素是目录中的条目。
|
static DirectoryStream<Path> |
Files.newDirectoryStream(Path dir)
打开目录,返回一个
DirectoryStream 遍历目录中的所有条目。
|
static DirectoryStream<Path> |
Files.newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter)
打开目录,返回一个
DirectoryStream 遍历目录中的条目。
|
static DirectoryStream<Path> |
Files.newDirectoryStream(Path dir, String glob)
打开目录,返回一个
DirectoryStream 遍历目录中的条目。
|
static Stream<Path> |
Files.walk(Path start, FileVisitOption... options)
返回一个
Stream ,懒洋洋地填充
Path 走文件树在一个给定的启动文件。
|
static Stream<Path> |
Files.walk(Path start, int maxDepth, FileVisitOption... options)
返回一个
Stream ,懒洋洋地填充
Path 走文件树在一个给定的启动文件。
|
Modifier and Type | Method and Description |
---|---|
int |
Path.compareTo(Path other)
比较两个抽象路径字典。
|
static long |
Files.copy(InputStream in, Path target, CopyOption... options)
将所有字节从输入流复制到文件。
|
static long |
Files.copy(Path source, OutputStream out)
将从文件到输出流的所有字节复制到输出流中。
|
static Path |
Files.copy(Path source, Path target, CopyOption... options)
将一个文件复制到目标文件。
|
static Path |
Files.createDirectories(Path dir, FileAttribute<?>... attrs)
创建一个目录,通过创建所有不存在的父目录。
|
static Path |
Files.createDirectory(Path dir, FileAttribute<?>... attrs)
创建一个新目录。
|
static Path |
Files.createFile(Path path, FileAttribute<?>... attrs)
创建一个新的和空的文件,如果文件已经存在,失败了。
|
static Path |
Files.createLink(Path link, Path existing)
创建一个新的链接(目录项)为现有的文件(可选操作)。
|
static Path |
Files.createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs)
创建一个符号链接到一个目标(可选操作)。
|
static Path |
Files.createTempDirectory(Path dir, String prefix, FileAttribute<?>... attrs)
在指定的目录中创建一个新的目录,使用给定的前缀来生成它的名称。
|
static Path |
Files.createTempFile(Path dir, String prefix, String suffix, FileAttribute<?>... attrs)
在指定的目录中创建一个新的空文件,使用给定的前缀和后缀字符串来生成它的名称。
|
static void |
Files.delete(Path path)
删除一个文件。
|
static boolean |
Files.deleteIfExists(Path path)
如果它存在的话,删除一个文件。
|
boolean |
Path.endsWith(Path other)
测试,如果这个路径结束与给定的路径。
|
static boolean |
Files.exists(Path path, LinkOption... options)
测试一个文件是否存在。
|
static Stream<Path> |
Files.find(Path start, int maxDepth, BiPredicate<Path,BasicFileAttributes> matcher, FileVisitOption... options)
返回一个
Stream ,懒洋洋地填充
Path 寻找一根在一个给定的启动文件树文件。
|
static Object |
Files.getAttribute(Path path, String attribute, LinkOption... options)
读取文件属性的值。
|
static <V extends FileAttributeView> |
Files.getFileAttributeView(Path path, 类<V> type, LinkOption... options)
返回一个给定类型的文件属性视图。
|
static FileStore |
Files.getFileStore(Path path)
返回
FileStore 代表文件存储在一个文件的位置。
|
static FileTime |
Files.getLastModifiedTime(Path path, LinkOption... options)
返回一个文件的最后修改时间。
|
static UserPrincipal |
Files.getOwner(Path path, LinkOption... options)
返回文件的所有者。
|
static Set<PosixFilePermission> |
Files.getPosixFilePermissions(Path path, LinkOption... options)
返回一个文件的POSIX文件权限。
|
static boolean |
Files.isDirectory(Path path, LinkOption... options)
测试一个文件是否是一个目录。
|
static boolean |
Files.isExecutable(Path path)
测试一个文件是否可执行。
|
static boolean |
Files.isHidden(Path path)
告诉是否一个文件被认为是隐藏的。
|
static boolean |
Files.isReadable(Path path)
测试一个文件是否可读。
|
static boolean |
Files.isRegularFile(Path path, LinkOption... options)
测试一个文件是否是一个不透明的内容的常规文件。
|
static boolean |
Files.isSameFile(Path path, Path path2)
测试如果两个路径定位相同的文件。
|
static boolean |
Files.isSymbolicLink(Path path)
测试一个文件是否是一个符号链接。
|
static boolean |
Files.isWritable(Path path)
测试文件是否可写。
|
static Stream<String> |
Files.lines(Path path)
阅读所有的线从一个文件作为一个
Stream 。
|
static Stream<String> |
Files.lines(Path path, Charset cs)
阅读所有的线从一个文件作为一个
Stream 。
|
static Stream<Path> |
Files.list(Path dir)
返回一个懒洋洋的密集
Stream ,其中的元素是目录中的条目。
|
boolean |
PathMatcher.matches(Path path)
如果给定的路径匹配这告诉匹配的模式。
|
static Path |
Files.move(Path source, Path target, CopyOption... options)
移动或重命名一个文件到目标文件。
|
static BufferedReader |
Files.newBufferedReader(Path path)
打开一个文件进行读取,返回一个
BufferedReader 以有效方式从文件中读取文本。
|
static BufferedReader |
Files.newBufferedReader(Path path, Charset cs)
打开一个文件进行读取,返回一个
BufferedReader 可以用来有效方式从文件中读取文本。
|
static BufferedWriter |
Files.newBufferedWriter(Path path, Charset cs, OpenOption... options)
打开或创建一个文件写入,返回一个
BufferedWriter ,可以有效的方式将文件写入文本。
|
static BufferedWriter |
Files.newBufferedWriter(Path path, OpenOption... options)
打开或创建一个文件写入,返回一个
BufferedWriter 能够以有效的方式的文件写入文本。
|
static SeekableByteChannel |
Files.newByteChannel(Path path, OpenOption... options)
打开或创建一个文件,返回一个可寻址的字节通道存取文件。
|
static SeekableByteChannel |
Files.newByteChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs)
打开或创建一个文件,返回一个可寻址的字节通道存取文件。
|
static DirectoryStream<Path> |
Files.newDirectoryStream(Path dir)
打开目录,返回一个
DirectoryStream 遍历目录中的所有条目。
|
static DirectoryStream<Path> |
Files.newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter)
打开目录,返回一个
DirectoryStream 遍历目录中的条目。
|
static DirectoryStream<Path> |
Files.newDirectoryStream(Path dir, String glob)
打开目录,返回一个
DirectoryStream 遍历目录中的条目。
|
static FileSystem |
FileSystems.newFileSystem(Path path, ClassLoader loader)
构建访问一个文件的内容作为一个文件系统的一个新的
FileSystem 。
|
static InputStream |
Files.newInputStream(Path path, OpenOption... options)
打开一个文件,返回一个输入流从文件中读取。
|
static OutputStream |
Files.newOutputStream(Path path, OpenOption... options)
打开或创建一个文件,返回一个可用于将字节写入文件的输出流。
|
static boolean |
Files.notExists(Path path, LinkOption... options)
测试位于此路径的文件是否不存在。
|
static String |
Files.probeContentType(Path path)
探测文件的内容类型。
|
static byte[] |
Files.readAllBytes(Path path)
读取文件中的所有字节。
|
static List<String> |
Files.readAllLines(Path path)
从文件中读取所有行。
|
static List<String> |
Files.readAllLines(Path path, Charset cs)
从文件中读取所有行。
|
static <A extends BasicFileAttributes> |
Files.readAttributes(Path path, 类<A> type, LinkOption... options)
读取一个文件的属性作为一个批量操作。
|
static Map<String,Object> |
Files.readAttributes(Path path, String attributes, LinkOption... options)
读取一组文件属性作为批量操作。
|
static Path |
Files.readSymbolicLink(Path link)
读一个符号链接的目标(可选操作)。
|
Path |
Path.relativize(Path other)
在这个路径和一个给定路径之间构造一个相对路径。
|
Path |
Path.resolve(Path other)
解决此路径的给定路径。
|
Path |
Path.resolveSibling(Path other)
解决给定的路径在路径的
parent 路径。
|
static Path |
Files.setAttribute(Path path, String attribute, Object value, LinkOption... options)
设置文件属性的值。
|
static Path |
Files.setLastModifiedTime(Path path, FileTime time)
更新一个文件的最后一次修改的时间属性。
|
static Path |
Files.setOwner(Path path, UserPrincipal owner)
更新文件所有者。
|
static Path |
Files.setPosixFilePermissions(Path path, Set<PosixFilePermission> perms)
设置文件的POSIX权限。
|
static long |
Files.size(Path path)
返回一个文件的大小(以字节为单位)。
|
boolean |
Path.startsWith(Path other)
测试,如果这个路径开始与给定的路径。
|
static Stream<Path> |
Files.walk(Path start, FileVisitOption... options)
返回一个
Stream ,懒洋洋地填充
Path 走文件树在一个给定的启动文件。
|
static Stream<Path> |
Files.walk(Path start, int maxDepth, FileVisitOption... options)
返回一个
Stream ,懒洋洋地填充
Path 走文件树在一个给定的启动文件。
|
static Path |
Files.walkFileTree(Path start, FileVisitor<? super Path> visitor)
走一个文件树。
|
static Path |
Files.walkFileTree(Path start, Set<FileVisitOption> options, int maxDepth, FileVisitor<? super Path> visitor)
走一个文件树。
|
static Path |
Files.write(Path path, byte[] bytes, OpenOption... options)
将字节写入到文件中。
|
static Path |
Files.write(Path path, Iterable<? extends CharSequence> lines, Charset cs, OpenOption... options)
写入文本到文件的行。
|
static Path |
Files.write(Path path, Iterable<? extends CharSequence> lines, OpenOption... options)
写入文本到文件的行。
|
Modifier and Type | Method and Description |
---|---|
static Stream<Path> |
Files.find(Path start, int maxDepth, BiPredicate<Path,BasicFileAttributes> matcher, FileVisitOption... options)
返回一个
Stream ,懒洋洋地填充
Path 寻找一根在一个给定的启动文件树文件。
|
static DirectoryStream<Path> |
Files.newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter)
打开目录,返回一个
DirectoryStream 遍历目录中的条目。
|
static Path |
Files.walkFileTree(Path start, FileVisitor<? super Path> visitor)
走一个文件树。
|
static Path |
Files.walkFileTree(Path start, Set<FileVisitOption> options, int maxDepth, FileVisitor<? super Path> visitor)
走一个文件树。
|
Modifier and Type | Method and Description |
---|---|
abstract Path |
FileSystemProvider.getPath(URI uri)
通过将给定的
URI 返回
Path 对象。
|
Path |
FileSystemProvider.readSymbolicLink(Path link)
读取符号链接的目标。
|
Modifier and Type | Method and Description |
---|---|
abstract DirectoryStream<Path> |
FileSystemProvider.newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter)
打开目录,返回一个
DirectoryStream 遍历目录中的条目。
|
Modifier and Type | Method and Description |
---|---|
abstract void |
FileSystemProvider.checkAccess(Path path, AccessMode... modes)
检查是否存在一个文件的存在性和可选的可访问性。
|
abstract void |
FileSystemProvider.copy(Path source, Path target, CopyOption... options)
将一个文件复制到目标文件。
|
abstract void |
FileSystemProvider.createDirectory(Path dir, FileAttribute<?>... attrs)
创建一个新目录。
|
void |
FileSystemProvider.createLink(Path link, Path existing)
为现有文件创建一个新的链接(目录项)。
|
void |
FileSystemProvider.createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs)
创建一个目标的符号链接。
|
abstract void |
FileSystemProvider.delete(Path path)
删除一个文件。
|
boolean |
FileSystemProvider.deleteIfExists(Path path)
如果它存在的话,删除一个文件。
|
abstract <V extends FileAttributeView> |
FileSystemProvider.getFileAttributeView(Path path, 类<V> type, LinkOption... options)
返回一个给定类型的文件属性视图。
|
abstract FileStore |
FileSystemProvider.getFileStore(Path path)
返回
FileStore 代表文件存储在一个文件的位置。
|
abstract boolean |
FileSystemProvider.isHidden(Path path)
告诉是否一个文件被认为是隐藏的。
|
abstract boolean |
FileSystemProvider.isSameFile(Path path, Path path2)
测试如果两个路径定位相同的文件。
|
abstract void |
FileSystemProvider.move(Path source, Path target, CopyOption... options)
移动或重命名一个文件到目标文件。
|
AsynchronousFileChannel |
FileSystemProvider.newAsynchronousFileChannel(Path path, Set<? extends OpenOption> options, ExecutorService executor, FileAttribute<?>... attrs)
打开或创建一个用于读取和/或写入的文件,返回一个异步文件通道来访问该文件。
|
abstract SeekableByteChannel |
FileSystemProvider.newByteChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs)
打开或创建一个文件,返回一个可寻址的字节通道存取文件。
|
abstract DirectoryStream<Path> |
FileSystemProvider.newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter)
打开目录,返回一个
DirectoryStream 遍历目录中的条目。
|
FileChannel |
FileSystemProvider.newFileChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs)
打开或创建一个用于读取和/或写入的文件,返回一个文件通道以访问该文件。
|
FileSystem |
FileSystemProvider.newFileSystem(Path path, Map<String,?> env)
构建访问一个文件的内容作为一个文件系统的一个新的
FileSystem 。
|
InputStream |
FileSystemProvider.newInputStream(Path path, OpenOption... options)
打开一个文件,返回一个输入流从文件中读取。
|
OutputStream |
FileSystemProvider.newOutputStream(Path path, OpenOption... options)
打开或创建一个文件,返回一个可用于将字节写入文件的输出流。
|
abstract String |
FileTypeDetector.probeContentType(Path path)
探测给定的文件来猜测它的内容类型。
|
abstract <A extends BasicFileAttributes> |
FileSystemProvider.readAttributes(Path path, 类<A> type, LinkOption... options)
读取一个文件的属性作为一个批量操作。
|
abstract Map<String,Object> |
FileSystemProvider.readAttributes(Path path, String attributes, LinkOption... options)
读取一组文件属性作为批量操作。
|
Path |
FileSystemProvider.readSymbolicLink(Path link)
读取符号链接的目标。
|
abstract void |
FileSystemProvider.setAttribute(Path path, String attribute, Object value, LinkOption... options)
设置文件属性的值。
|
Modifier and Type | Method and Description |
---|---|
abstract DirectoryStream<Path> |
FileSystemProvider.newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter)
打开目录,返回一个
DirectoryStream 遍历目录中的条目。
|
Constructor and Description |
---|
Scanner(Path source)
构建产生扫描指定的文件价值的一个新
Scanner 。
|
Scanner(Path source, String charsetName)
构建产生扫描指定的文件价值的一个新
Scanner 。
|
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.