OCP - 4
NIO.2, JDBC
NIO.2, JDBC
Fichier Détails
Cartes-fiches | 66 |
---|---|
Langue | English |
Catégorie | Informatique |
Niveau | Autres |
Crée / Actualisé | 30.04.2019 / 08.01.2020 |
Attribution de licence | Non précisé |
Lien de web |
https://card2brain.ch/box/20190430_ocp_4
|
Intégrer |
<iframe src="https://card2brain.ch/box/20190430_ocp_4/embed" width="780" height="150" scrolling="no" frameborder="0"></iframe>
|
What is the goal of the NIO.2 API?
To provide a replacement for the java.io.FIle class
What is the java.nio.file.Path class for?
It represents a path on the storage system to a file or directory. Its the direct replacement for the java.io.File class.
It can represent a File, Directory or Symlink
How can you construct a Path object?
- Using the Paths factory class, eg. Phats.get(...)
- by prividing one or multiple Strings
- by providing a URI
- Using a FileSystem instance, eg. Filesystem.getPath(...)
- From a Legacy File instance: aFIle.toPath()
Note that Path is an Interface!
Does it matter which path separator you use when constructing a Path?
Usually not, as most JVMs support both forward and backward slashes.
How can you simply construct a phat without using a path separator
Using the Path.get(String, String...) varargs overload
What happens when constructing a path with a URI to a relative path?
Paths.get(new URI("file://relative/path"));
An IllegalArgumentException is thrown
What has to be considered when using the URI constructor?
It throws a checked URISyntaxException
How can you convert a Path to a URI
Using the toUri() method