Code example for StreamSource

Methods: getInputStream, getReader

0
        } 
 
        private void validateStreamSource(StreamSource streamSource,
                                          SAXParser parser,
                                          DefaultValidationErrorHandler errorHandler) throws SAXException, IOException {
            if (streamSource.getInputStream() != null) {
                parser.parse(streamSource.getInputStream(), errorHandler);
            } 
            else if (streamSource.getReader() != null) {
                parser.parse(new InputSource(streamSource.getReader()), errorHandler);
            } 
            else { 
                throw new IllegalArgumentException("StreamSource contains neither InputStream nor Reader");
            } 
        } 
 
        private void validateSAXSource(SAXSource source, SAXParser parser, DefaultValidationErrorHandler errorHandler)
                throws SAXException, IOException { 
            parser.parse(source.getInputSource(), errorHandler);
        }