NIO 2 File API: Difference between revisions
Jump to navigation
Jump to search
Line 2: | Line 2: | ||
* https://gquintana.github.io/2017/09/02/Java-File-vs-Path.html | * https://gquintana.github.io/2017/09/02/Java-File-vs-Path.html | ||
* https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/Files.html | * https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/Files.html | ||
* https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/Paths.html | |||
=Internal= | =Internal= |
Revision as of 01:29, 2 April 2021
External
- https://gquintana.github.io/2017/09/02/Java-File-vs-Path.html
- https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/Files.html
- https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/Paths.html
Internal
Subjects
Recipes
Create one directory:
Path parent = ...;
Path dir = Files.createDirectory(Paths.get(parent.toString(), "my-dir"));
Create a directory hierarchy:
Path parent = ...;
Path dir = Files.createDirectories(Paths.get(parent.toString(), "dir1/dir2/dir3"));
Get file name:
Path file = ...;
String fileName = file.getFileName().toString();
Create a file with a specified content:
Path file = ...;
Files.write(file, "something".getBytes());