Interface Resource

All Known Implementing Classes:
Resources.ByteArrayResource, Resources.ClasspathResource, Resources.FileSystemResource, Resources.UrlResource

public interface Resource
Describe a resource, such as a file or class path resource.
  • Method Details

    • getLocation

      String getLocation()
      The location of the resource.
    • exists

      boolean exists()
      Whether this resource exists.
    • getURI

      default URI getURI()
      The URI of the resource.

      The default implementation creates a URI object from resource location.
    • getURL

      default URL getURL() throws MalformedURLException
      The URL for the resource or null if the URL can not be computed.

      The default implementation creates a URI object from resource location.
      Throws:
      MalformedURLException
    • getInputStream

      InputStream getInputStream()
      Returns an InputStream that reads from the underlying resource.

      Each invocation must return a new InputStream instance.
    • getFile

      File getFile()
      Return the file associated with this resource.
      Returns:
    • getReader

      default Reader getReader() throws IOException
      Returns a Reader that reads from the underlying resource using UTF-8 as charset.

      Each invocation must return a new Reader.
      Throws:
      IOException
      See Also:
    • getReader

      default Reader getReader(Charset charset) throws IOException
      Returns a Reader that reads from the underlying resource using the given Charset

      Each invocation must return a new Reader.
      Throws:
      IOException
      See Also: