public class NamedInputStream extends NamedCloseable
Constructor and Description |
---|
NamedInputStream(java.lang.String name,
java.io.InputStream stream)
Create a new instance with the given name associated to the given input stream.
|
Modifier and Type | Method and Description |
---|---|
protected java.io.Closeable |
getCloseable()
Returns the closeable that is associated with the name defined in this class.
|
java.io.InputStream |
getInputStream()
Returns the underlying InputStream (will never be null).
|
static NamedInputStream |
open(java.io.File file)
Opens the provided file and returns the input stream along with the file name.
|
static NamedInputStream |
open(java.lang.String filename)
Opens the file specified by the given filename and returns the input stream along with the file name.
|
close, getName, setName
public NamedInputStream(java.lang.String name, java.io.InputStream stream)
name
- The name of the input stream (must not be null).stream
- The input stream to be associated with the name (must not be null).java.lang.IllegalArgumentException
- If either name or stream is null.public static NamedInputStream open(java.io.File file) throws java.io.FileNotFoundException
file
- The file to be opened (must not be null).java.io.FileNotFoundException
- If the provided file cannot be found.public static NamedInputStream open(java.lang.String filename) throws java.io.FileNotFoundException
filename
- The file to be opened (must not be null).java.io.FileNotFoundException
- If a file with the given name cannot be found.public java.io.InputStream getInputStream()
protected java.io.Closeable getCloseable()
NamedCloseable
getCloseable
in class NamedCloseable