Class Nio2Examples

java.lang.Object
net.jrodolfo.java_evolution.java07.Nio2Examples

public class Nio2Examples extends Object
Demonstrates NIO.2 filesystem APIs introduced in Java 7.
  • Constructor Details

    • Nio2Examples

      public Nio2Examples()
  • Method Details

    • resolveChild

      public Path resolveChild(Path root, String child)
      Resolves a child path from a root path.
      Parameters:
      root - root directory
      child - child name
      Returns:
      resolved path
    • fileSize

      public long fileSize(Path path) throws IOException
      Reads basic file attributes through Files.
      Parameters:
      path - file to inspect
      Returns:
      size in bytes
      Throws:
      IOException - when attributes cannot be read
    • regularFileNames

      public List<String> regularFileNames(Path directory) throws IOException
      Lists regular file names in a directory.
      Parameters:
      directory - directory to inspect
      Returns:
      sorted regular file names
      Throws:
      IOException - when listing fails