Class FileSystemsNewFileSystemExamples

java.lang.Object
net.jrodolfo.java_evolution.java13.FileSystemsNewFileSystemExamples

public class FileSystemsNewFileSystemExamples extends Object
Demonstrates the FileSystems.newFileSystem(Path) convenience overload added in Java 13.

Before Java 13, opening an archive or other provider-backed path as a file system required more verbose overloads. That added ceremony to the common case where the path itself contained enough information.

The Java 13 overload solves that convenience problem by letting code open a supported file system directly from a Path.

  • Constructor Details

    • FileSystemsNewFileSystemExamples

      public FileSystemsNewFileSystemExamples()
  • Method Details

    • readTextFromArchive

      public String readTextFromArchive(Path archivePath, String fileName) throws IOException
      Opens a file system from a path, reads one file, and closes the file system.
      Parameters:
      archivePath - path to an archive supported by an installed file system provider
      fileName - the file inside the archive to read
      Returns:
      the file content
      Throws:
      IOException - when the archive cannot be opened or read