|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
edu.mit.jmwe.util.StreamAdapter
public class StreamAdapter
An adapter that makes a ByteBuffer
look like an InputStream
.
Field Summary | |
---|---|
static String |
FILE_PROTOCOL
The string that indicates the file protocol. |
static String |
UTF8
The string that indicates the UTF8 character encoding. |
Constructor Summary | |
---|---|
StreamAdapter(ByteBuffer buffer)
Creates a new instance of this class that wraps the specified buffer as an InputStream . |
Method Summary | |
---|---|
int |
available()
|
void |
close()
|
static InputStream |
make(File file)
Returns an input stream on the specified file that is backed by a mapped byte buffer, making it much faster than a normal FileInputStream . |
static InputStream |
make(URL url)
Returns an input stream for the specified URL . |
void |
mark(int readlimit)
|
boolean |
markSupported()
|
int |
read()
|
void |
reset()
|
static File |
toFile(URL url)
Transforms the specified URL into a File object, if in
fact the URL points to a file. |
static URL |
toURL(File file)
Transforms a file into a URL |
Methods inherited from class java.io.InputStream |
---|
read, read, skip |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String FILE_PROTOCOL
public static final String UTF8
Constructor Detail |
---|
public StreamAdapter(ByteBuffer buffer)
InputStream
.
NullPointerException
- if the specified buffer is null
Method Detail |
---|
public int available() throws IOException
available
in class InputStream
IOException
public int read() throws IOException
read
in class InputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in class InputStream
IOException
public void mark(int readlimit)
mark
in class InputStream
public void reset() throws IOException
reset
in class InputStream
IOException
public boolean markSupported()
markSupported
in class InputStream
public static File toFile(URL url)
URL
into a File
object, if in
fact the URL
points to a file. That is, if the URL
uses
the file:// protocol and is in UTF8 encoding. If the
transformation cannot be done, this method returns null
.
NullPointerException
- if the specified URL is null
public static URL toURL(File file)
file
- the file to be transformed
NullPointerException
- if the specified file is null
public static InputStream make(URL url) throws IOException
URL
. This
implementation produces a mapped byte-buffer wrapped as a stream if the
specified URL
points to a local file system resource.
NullPointerException
- if the specified URL
is null
IOException
public static InputStream make(File file) throws IOException
FileInputStream
.
file
- the file on which to open the stream
IOException
- if there was a io error accessing the file
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |