Class URLResource

java.lang.Object
io.smallrye.common.resource.Resource
io.smallrye.common.resource.URLResource

public final class URLResource extends Resource
A resource backed by a connection to a URL.
  • Constructor Details

    • URLResource

      public URLResource(String pathName, URL url) throws IOException
      Construct a new instance for a URL.
      Parameters:
      pathName - the resource path name (must not be null)
      url - the URL (must not be null)
      Throws:
      IOException - if the connection could not be opened
    • URLResource

      public URLResource(String pathName, URLConnection connection)
      Construct a new instance.
      Parameters:
      pathName - the resource path name (must not be null)
      connection - the URL connection (must not be null)
    • URLResource

      public URLResource(JarURLConnection jarConnection)
      Construct a new instance for a JAR URL connection. The JAR entry name is used as the resource name.
      Parameters:
      jarConnection - the JAR URL connection (must not be null)
  • Method Details

    • url

      public URL url()
      Description copied from class: Resource
      Returns the resource URL (not null). If the resource location information cannot be converted to a URL, an exception may be thrown.
      Specified by:
      url in class Resource
      Returns:
      the resource URL (not null)
    • openStream

      public InputStream openStream() throws IOException
      Description copied from class: Resource
      Open an input stream to read this resource.
      Specified by:
      openStream in class Resource
      Returns:
      the input stream (not null)
      Throws:
      IOException - if the input stream could not be opened or the resource is a directory
    • modifiedTime

      public Instant modifiedTime()
      Description copied from class: Resource
      Returns the modification time of the resource, or null if the time is unknown.
      Overrides:
      modifiedTime in class Resource
      Returns:
      the modification time of the resource, or null if the time is unknown
    • size

      public long size()
      Description copied from class: Resource
      Returns the size of the resource, or -1 if the size is not known.
      Specified by:
      size in class Resource
      Returns:
      the size of the resource, or -1 if the size is not known