Top Description Methods
org.junit.platform.commons.io

public Interface Resource

Known Direct Subinterfaces
org.junit.platform.commons.support.Resource
Known Direct Implementers
org.junit.platform.commons.io.DefaultResource
Annotations
@API
status:MAINTAINED
since:1.14
Static Imports
org.apiguardian.api.API.Status.MAINTAINED

Resource represents a resource on the classpath.

Warning

a Resource must provide correct equals and hashCode implementations since a Resource may potentially be stored in a collection or map.

Since
1.14
See Also
org.junit.platform.commons.support.ResourceSupport

Method Summary

Modifier and TypeMethod and Description
public default InputStream

Returns:

an input stream for this resource; never null
getInputStream
()

Get an InputStream for reading this resource.

public String

Returns:

the resource name; never null
getName
()

Get the name of this resource.

public URI

Returns:

the URI of the resource; never null
getUri
()

Get the URI of this resource.

public static Resource

Returns:

a new Resource
of
(String
the name of the resource; never null
name
,
URI
the URI of the resource; never null
uri
)

Create a new Resource with the given name and URI.

Method Detail

getInputStreamback to summary
public default InputStream getInputStream() throws IOException

Get an InputStream for reading this resource.

The default implementation delegates to java.net.URL#openStream() for this resource's URI.

Returns:InputStream

an input stream for this resource; never null

Exceptions
IOException:
if an I/O exception occurs
getNameback to summary
public String getName()

Get the name of this resource.

The resource name is a /-separated path. The path is relative to the classpath root in which the resource is located.

Returns:String

the resource name; never null

getUriback to summary
public URI getUri()

Get the URI of this resource.

Returns:URI

the URI of the resource; never null

ofback to summary
public static Resource of(String name, URI uri)

Create a new Resource with the given name and URI.

Parameters
name:String

the name of the resource; never null

uri:URI

the URI of the resource; never null

Returns:Resource

a new Resource

Since
1.14