public final class Input extends Object
InputStream
.Constructor and Description |
---|
Input(File file) |
Input(String description,
InputStream is) |
Input(URL url) |
Modifier and Type | Method and Description |
---|---|
Input |
copy()
Get a fresh version of this Input - i.e.
|
String |
getContentAsString() |
String |
getDescription() |
static Input |
getInput(File file)
factory method for creating an
Input . |
static Input |
getInput(String resourceName)
searches for the given resource name as follows:
if resourceName contains :// we try to load it as a URL
if resourceName is an absolute filename the corresponding Input is created
resourceName is searched in the classpath
resourceName is searched relative to System.getProperty(SystemProperties.JREALITY_DATA)
resourceName is searched relative to the current dir
|
static Input |
getInput(String description,
InputStream in)
factory method for creating an
Input . |
static Input |
getInput(URL url)
factory method for creating an
Input . |
InputStream |
getInputStream() |
Reader |
getReader()
Creates a Reader for this Input
|
Reader |
getReader(String encoding)
Creates a Reader for this Input with given encoding.
|
Input |
getRelativeInput(String name)
Tries to resolve a Resource relative to this Input.
|
Input |
resolveInput(String name)
Tries to create an Input for the given name as follows:
if there is a System resource with the given name, this is returned.
|
File |
toFile()
returns a
File for this Input if possible. |
String |
toString() |
URL |
toURL()
returns a
URL for this Input if possible. |
public Input(URL url) throws IOException
IOException
public Input(File file) throws FileNotFoundException
FileNotFoundException
public Input(String description, InputStream is)
public InputStream getInputStream()
public Reader getReader()
public Reader getReader(String encoding) throws UnsupportedEncodingException
encoding
- the encoding to use for the created ReaderUnsupportedEncodingException
public Input getRelativeInput(String name) throws IOException
name
- the relative name for the resource.IOException
- if no such relative resource was found.public Input resolveInput(String name) throws IOException
name
- the name of the resource.IOException
- if sth. goes wrong.public File toFile() throws UnsupportedOperationException
File
for this Input if possible.UnsupportedOperationException
- if this Input is not from a file.public URL toURL() throws MalformedURLException
URL
for this Input if possible.MalformedURLException
- if this Input can't be converted to a URL.public String getDescription()
public static Input getInput(URL url) throws IOException
Input
.url
- the URL to create the Input for.IOException
public static Input getInput(File file) throws IOException
Input
.file
- the file to create the Input for.IOException
public static Input getInput(String description, InputStream in) throws IOException
Input
.in
- the InputStream to create the Input for.description
- a String describing the type of input.IOException
public static Input getInput(String resourceName) throws IOException
resourceName
- the name of the resource to look forIOException
public Input copy() throws IOException
IOException
public String getContentAsString() throws IOException
IOException