javolution37.javolution.xml
Class XmlInputStream<T>
- java.lang.Object
-
- java.io.InputStream
-
- javolution37.javolution.xml.XmlInputStream<T>
-
- All Implemented Interfaces:
- java.io.Closeable, java.lang.AutoCloseable, Reusable
public class XmlInputStream<T> extends java.io.InputStream implements Reusable
This class represents an object input stream using
ObjectReaderfor object deserialization.Instances of this class embed their own data buffer, wrapping using a
java.io.BufferedInputStreamis therefore unnescessary.- See Also:
XmlOutputStream
-
-
Constructor Summary
Constructors Constructor and Description XmlInputStream()Default constructor.XmlInputStream(ObjectReader<T> reader)Creates a xml input stream using the specified object reader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidclose()Closes andresetsthis stream for reuse.intread()Reads the next byte of data from the input stream.intread(byte[] b, int off, int len)Reads up to len bytes of data from the input stream into an array of bytes.TreadObject()Reads an object from the underlying stream using anObjectReader.voidreset()Resets the internal state of this object to its default values.XmlInputStreamsetInputStream(java.io.InputStream in)Sets the underlying input source for this stream.
-
-
-
Constructor Detail
-
XmlInputStream
public XmlInputStream()
Default constructor.
-
XmlInputStream
public XmlInputStream(ObjectReader<T> reader)
Creates a xml input stream using the specified object reader.- Parameters:
reader- the object reader.
-
-
Method Detail
-
setInputStream
public XmlInputStream setInputStream(java.io.InputStream in)
Sets the underlying input source for this stream.
-
readObject
public T readObject() throws java.io.IOException
Reads an object from the underlying stream using anObjectReader.- Returns:
- the object read from its xml representation.
- Throws:
java.io.IOException- if an I/O error occurs.
-
close
public void close() throws java.io.IOExceptionCloses andresetsthis stream for reuse.- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfacejava.lang.AutoCloseable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException- if an I/O error occurs.
-
read
public int read() throws java.io.IOExceptionReads the next byte of data from the input stream.- Specified by:
readin classjava.io.InputStream- Returns:
- the next byte of data, or -1 if the end of the stream is reached.
- Throws:
java.io.IOException- if an I/O error occurs.
-
read
public int read(byte[] b, int off, int len) throws java.io.IOExceptionReads up to len bytes of data from the input stream into an array of bytes.- Overrides:
readin classjava.io.InputStream- Parameters:
b- the buffer into which the data is read.off- the start offset in array b at which the data is written.len- the maximum number of bytes to read.- Returns:
- the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
- Throws:
java.io.IOException- if an I/O error occurs.
-
-
DMelt 3.0 © DataMelt by jWork.ORG