Class FileSystemItemAccessor

java.lang.Object
ch.nolix.base.environment.filesystem.FileSystemItemAccessor
Direct Known Subclasses:
FileAccessor, FolderAccessor

public class FileSystemItemAccessor extends Object
A file system item accessor can access a given file system item. A file system item is a file or a folder.
Author:
Silvan Wyss
  • Method Details

    • withPath

      public static FileSystemItemAccessor withPath(String path)
      Parameters:
      path -
      Returns:
      a new FileSystemItemAccessorfor the file system item with the given path.
      Throws:
      RuntimeException - if there does not exist a file system item with the given path in the file system on the local machine.
    • getExtension

      public final String getExtension()
      Returns:
      the extension of the name of the file system item of the current FileSystemItemAccessor.
    • getName

      public final String getName()
      Returns:
      the name of the file system item of the current FileSystemItemAccessor.
    • getParentFolderAccessor

      public final FolderAccessor getParentFolderAccessor()
      Returns:
      a new folder accessor to the parent folder of the file system item of this file system item accessor.
    • getPath

      public final String getPath()
      Returns:
      the path of the file system item of this file system item accessor.
    • hasExtension

      public final boolean hasExtension(String extension)
      Parameters:
      extension -
      Returns:
      true if the file system item of the current FileSystemItemAccessor has the given extension, false otherwise.
    • getSizeInBytes

      public long getSizeInBytes()
      Returns:
      the size of the file system item of this file system item accessor in bytes.
    • isFile

      public final boolean isFile()
      Returns:
      true if the file system item is a file in the file system on the local machine, false otherwise.
    • isFolder

      public final boolean isFolder()
      Returns:
      true if this path is a folder in the file system on the local machine, false otherwise.
    • openParentFolder

      public final void openParentFolder()
      Opens the parent folder of the file system item of this file system item accessor in the file explorer.