Package org.junit.platform.commons.io
Interface Resource
-
- All Known Subinterfaces:
Resource
@API(status=MAINTAINED, since="1.14") public interface ResourceResourcerepresents a resource on the classpath.WARNING: a
Resourcemust provide correctequalsandhashCodeimplementations since aResourcemay potentially be stored in a collection or map.- Since:
- 1.14
- See Also:
ResourceSupport.findAllResourcesInClasspathRoot(URI, ResourceFilter),ResourceSupport.findAllResourcesInPackage(String, ResourceFilter),ResourceSupport.findAllResourcesInModule(String, ResourceFilter),ResourceSupport.streamAllResourcesInClasspathRoot(URI, ResourceFilter),ResourceSupport.streamAllResourcesInPackage(String, ResourceFilter),ResourceSupport.streamAllResourcesInModule(String, ResourceFilter)
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default java.io.InputStreamgetInputStream()Get anInputStreamfor reading this resource.java.lang.StringgetName()Get the name of this resource.java.net.URIgetUri()Get the URI of this resource.static Resourceof(java.lang.String name, java.net.URI uri)Create a newResourcewith the given name and URI.
-
-
-
Method Detail
-
of
static Resource of(java.lang.String name, java.net.URI uri)
Create a newResourcewith the given name and URI.- Parameters:
name- the name of the resource; nevernulluri- the URI of the resource; nevernull- Returns:
- a new
Resource - Since:
- 1.14
-
getName
java.lang.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:
- the resource name; never
null
-
getUri
java.net.URI getUri()
Get the URI of this resource.- Returns:
- the URI of the resource; never
null
-
getInputStream
default java.io.InputStream getInputStream() throws java.io.IOExceptionGet anInputStreamfor reading this resource.The default implementation delegates to
URL.openStream()for this resource'sURI.- Returns:
- an input stream for this resource; never
null - Throws:
java.io.IOException- if an I/O exception occurs
-
-