Package io.github.classgraph
Class ModuleReaderProxy
- java.lang.Object
-
- io.github.classgraph.ModuleReaderProxy
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class ModuleReaderProxy extends Object implements Closeable
A ModuleReader proxy, written using reflection to preserve backwards compatibility with JDK 7 and 8.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Calls ModuleReader#close().List<String>
list()
Get the list of resources accessible to a ModuleReader.InputStream
open(String path)
Use the proxied ModuleReader to open the named resource as an InputStream.ByteBuffer
read(String path)
Use the proxied ModuleReader to open the named resource as a ByteBuffer.void
release(ByteBuffer byteBuffer)
Release aByteBuffer
allocated by callingread(String)
.
-
-
-
Method Detail
-
close
public void close()
Calls ModuleReader#close().- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
list
public List<String> list() throws IOException, SecurityException
Get the list of resources accessible to a ModuleReader. From the documentation for ModuleReader#list(): "Whether the stream of elements includes names corresponding to directories in the module is module reader specific. In lazy implementations then an IOException may be thrown when using the stream to list the module contents. If this occurs then the IOException will be wrapped in an java.io.UncheckedIOException and thrown from the method that caused the access to be attempted. SecurityException may also be thrown when using the stream to list the module contents and access is denied by the security manager."- Returns:
- A list of the paths of resources in the module.
- Throws:
IOException
- If the module cannot be read.SecurityException
- If the module cannot be accessed.
-
open
public InputStream open(String path) throws IOException, SecurityException
Use the proxied ModuleReader to open the named resource as an InputStream.- Parameters:
path
- The path to the resource to open.- Returns:
- An
InputStream
for the content of the resource. - Throws:
IOException
- If the resource cannot be read.SecurityException
- If the module cannot be accessed.
-
read
public ByteBuffer read(String path) throws IOException, SecurityException, OutOfMemoryError
Use the proxied ModuleReader to open the named resource as a ByteBuffer. Call release(byteBuffer) when you have finished with the ByteBuffer.- Parameters:
path
- The path to the resource to open.- Returns:
- A
ByteBuffer
for the content of the resource. - Throws:
IOException
- If the resource cannot be read.SecurityException
- If the module cannot be accessed.OutOfMemoryError
- if the resource is larger than Integer.MAX_VALUE, the maximum capacity of a byte buffer.
-
release
public void release(ByteBuffer byteBuffer)
Release aByteBuffer
allocated by callingread(String)
.- Parameters:
byteBuffer
- TheByteBuffer
to release.
-
-