Class JavaResource

java.lang.Object
ch.bailu.gtk.lib.util.JavaResource

public class JavaResource extends Object
Util class for location-independent access to program specific resources. To read files from "resources/" or from the applications jar archive
  • Constructor Details

    • JavaResource

      public JavaResource(String path)
      Creates a JavaResource object holding a relative path to a file in "resources/" or the root directory of the jar archive
      Parameters:
      path - absolute path to css resource: "/css/app.css"
  • Method Details

    • asString

      public String asString() throws IOException
      Read entire text resource into string
      Returns:
      String containing the entire text resource
      Throws:
      IOException - If file does not exist
    • asStream

      public InputStream asStream() throws IOException
      Open the program specific resource file and return it as a readable stream
      Returns:
      InputStream for reading resource file
      Throws:
      IOException - If file does not exist
    • asBytes

      public Bytes asBytes() throws IOException
      Throws:
      IOException