Module watamebot

Class ModuleResource

java.lang.Object
net.foxgenesis.util.resource.ModuleResource
Direct Known Subclasses:
FormattedModuleResource

public class ModuleResource extends Object
A class that points to a resource inside a module and implements methods to read from it.
Author:
Ashley
  • Constructor Details

  • Method Details

    • openStream

      public InputStream openStream() throws IOException
      Open an InputStream to this resource.
      Returns:
      Returns an InputStream of this resource.
      Throws:
      IOException - If an I/O error occurs
    • writeToFile

      public void writeToFile(@NotNull @NotNull Path path, CopyOption... options) throws IOException
      Copy this resource to the specified path.
      Parameters:
      path - - Path tp copy to
      options - - options specifying how the copy should be done
      Throws:
      IOException - If an I/O error occurs when reading or writing
    • readToString

      public String readToString() throws IOException
      Read all data from this resource into a string.
      Returns:
      All data inside the resource as a string
      Throws:
      IOException - If an I/O error occurs
    • readAllLines

      public String[] readAllLines() throws IOException
      Read all lines from this resource.
      Returns:
      All data inside the resource as an array of strings
      Throws:
      IOException - If an I/O error occurs
    • asProperties

      public Properties asProperties() throws IOException
      Read this resource as a Properties file.
      Returns:
      Returns the parsed Properties
      Throws:
      IOException - If an I/O error occurs
    • getModule

      public Module getModule()
      Get the Module containing this resource.
      Returns:
      The containing Module
    • getResourcePath

      public String getResourcePath()
      Get the path to this resource.
      Returns:
      Returns the absolute path pointing to this resource
    • toString

      public String toString()
      Overrides:
      toString in class Object