Interface WebResource

All Known Implementing Classes:
WebResource.ByteResource

public interface WebResource
Represents a customizable resource.

You can use the create methods for simple resources when using ResourceService.

It is assumed that any text based files are encoded in UTF-8.

  • Method Details

    • create

      static WebResource create(byte[] content)
      Create a new WebResource from byte array.
      Parameters:
      content - Bytes of the resource.
      Returns:
      WebResource.
    • create

      static WebResource create(String utf8String)
      Create a new WebResource from an UTF-8 String.
      Parameters:
      utf8String - String in UTF-8 encoding.
      Returns:
      WebResource.
    • create

      static WebResource create(InputStream in) throws IOException
      Creates a new WebResource from an InputStream.
      Parameters:
      in - InputStream for the resource, closed after inside the method.
      Returns:
      WebResource.
      Throws:
      IOException - If the stream can not be read.
    • asBytes

      byte[] asBytes()
    • asString

      String asString()
      Return the resource as a UTF-8 String.
      Returns:
      The resource in UTF-8.
    • asStream

      InputStream asStream()