org.freehep.util.io
Class XMLSequence
- java.lang.Object
-
- java.io.InputStream
-
- org.freehep.util.io.XMLSequence
-
- All Implemented Interfaces:
- java.io.Closeable, java.lang.AutoCloseable
public class XMLSequence extends java.io.InputStreamThe XMLSequence allows parsing by an XML Parser of concatenated XML segments. Each segment needs to start with " XMLSequence sequence = new XMLSequence(new FileInputStream("file.xml")); SAXParserFactory factory = SAXParserFactory.newInstance(); XMLReader xmlReader = factory.newSAXParser().getXMLReader(); while (sequence.hasNext()) { InputStream input = sequence.next(); InputSource source = new InputSource(input); xmlReader.parse(source); input.close(); } sequence.close(); IMPORTANT: inherits from InputStream rather than FilterInputStream so that the correct read(byte[], int, int) method is used.
-
-
Constructor Summary
Constructors Constructor and Description XMLSequence(java.io.InputStream input)Create a XML Sequence.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidclose()booleanhasNext()Is another XML segment available.voidmark(int readLimit)booleanmarkSupported()java.io.InputStreamnext()Returns the next XML segment.intread()voidreset()
-
-
-
Constructor Detail
-
XMLSequence
public XMLSequence(java.io.InputStream input)
Create a XML Sequence.- Parameters:
input- stream to read from
-
-
Method Detail
-
hasNext
public boolean hasNext()
Is another XML segment available.- Returns:
- true if another XML segment can be read
-
next
public java.io.InputStream next() throws java.io.IOExceptionReturns the next XML segment.- Returns:
- stream to read next XML segment from.
- Throws:
java.io.IOException- if read fails
-
read
public int read() throws java.io.IOException- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
mark
public void mark(int readLimit)
- Overrides:
markin classjava.io.InputStream
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classjava.io.InputStream
-
reset
public void reset() throws java.io.IOException- Overrides:
resetin classjava.io.InputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfacejava.lang.AutoCloseable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException
-
-
DMelt 3.0 © DataMelt by jWork.ORG