Class Resource

java.lang.Object
com.codingchili.core.files.Resource

public class Resource extends Object
Reads a file from the filesystem or the classpath.
  • Constructor Details

    • Resource

      public Resource(String path)
      Creates a new resource reference.
      Parameters:
      path - path to the resource (classpath or file.)
  • Method Details

    • read

      public Optional<io.vertx.core.buffer.Buffer> read()
      Reads a file from the filesystem or the classpath. Prefers resources on the filesystem as bundled files on the classpath may be overriden.
      Returns:
      a buffer if found on the classpath or filesystem.
    • write

      public void write(io.vertx.core.buffer.Buffer buffer)
    • readFromFS

      public Optional<io.vertx.core.buffer.Buffer> readFromFS()
      Reads a resource from the filesystem.
      Returns:
      a buffer if the file is loaded successfully.
    • readFromCP

      public Optional<io.vertx.core.buffer.Buffer> readFromCP()
      Reads a resource from the classpath.
      Returns:
      a buffer if the classpath resource is loaded successfully