Karten 66 Karten
Lernende 2 Lernende
Sprache English
Stufe Andere
Erstellt / Aktualisiert 30.04.2019 / 08.01.2020
Lizenzierung Keine Angabe
0 Exakte Antworten 65 Text Antworten 1 Multiple Choice Antworten
Fenster schliessen

What is the goal of the NIO.2 API?

To provide a replacement for the java.io.FIle class

Fenster schliessen

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

Fenster schliessen

How can you construct a Path object?

  1. Using the Paths factory class, eg. Phats.get(...)
    1. by prividing one or multiple Strings
    2. by providing a URI
  2. Using a FileSystem instance, eg. Filesystem.getPath(...)
  3. From a Legacy File instance: aFIle.toPath()

Note that Path is an Interface!

Fenster schliessen

Does it matter which path separator you use when constructing a Path?

Usually not, as most JVMs support both forward and backward slashes.

Fenster schliessen

How can you simply construct a phat without using a path separator

Using the Path.get(String, String...) varargs overload

Fenster schliessen

What happens when constructing a path with a URI to a relative path?

Paths.get(new URI("file://relative/path"));

Fenster schliessen

What has to be considered when using the URI constructor?

It throws a checked URISyntaxException

Fenster schliessen

How can you convert a Path to a URI

Using the toUri() method