java.io.File Functionality | java.nio.file Functionality | Tutorial Coverage |
java.io.File | java.nio.file.Path | |
java.io.RandomAccessFile | The SeekableByteChannel functionality. | |
File.canRead, canWrite, canExecute | Files.isReadable, Files.isWritable, and Files.isExecutable. On UNIX file systems, the Managing Metadata (File and File Store Attributes) package is used to check the nine file permissions. | |
File.isDirectory(), File.isFile(), and File.length() | Files.isDirectory(Path, LinkOption...), Files.isRegularFile(Path, LinkOption...), and Files.size(Path) | |
File.lastModified() and File.setLastModified(long) | Files.getLastModifiedTime(Path, LinkOption...) and Files.setLastMOdifiedTime(Path, FileTime) | |
The File methods that set various attributes: setExecutable, setReadable, setReadOnly, setWritable | These methods are replaced by the Files method setAttribute(Path, String, Object, LinkOption...). | |
new File(parent, "newfile") | parent.resolve("newfile") | |
File.renameTo | Files.move | |
File.delete | Files.delete | |
File.createNewFile | Files.createFile | |
File.deleteOnExit | Replaced by the DELETE_ON_CLOSE option specified in the createFile method. | |
File.createTempFile | Files.createTempFile(Path, String, FileAttributes<?>), Files.createTempFile(Path, String, String, FileAttributes<?>) | |
File.exists | Files.exists and Files.notExists | |
File.compareTo and equals | Path.compareTo and equals | |
File.getAbsolutePath and getAbsoluteFile | Path.toAbsolutePath | |
File.getCanonicalPath and getCanonicalFile | Path.toRealPath or normalize | |
File.toURI | Path.toURI | |
File.isHidden | Files.isHidden | |
File.list and listFiles | Path.newDirectoryStream | |
File.mkdir and mkdirs | Path.createDirectory | |
File.listRoots | FileSystem.getRootDirectories | |
File.getTotalSpace, File.getFreeSpace, File.getUsableSpace | FileStore.getTotalSpace, FileStore.getUnallocatedSpace, FileStore.getUsableSpace, FileStore.getTotalSpace |